0.1.5
edit route url
This commit is contained in:
@@ -11,6 +11,8 @@ urlpatterns = [
|
||||
path('login/', login_ajax, name='login_ajax'),
|
||||
|
||||
path('new_route_view/', new_route_view_ajax, name='new_route_view_ajax'),
|
||||
|
||||
|
||||
path('my_routes/', my_routes_ajax, name='my_routes_ajax'),
|
||||
path('subscribe/', subscribe_ajax, name='subscribe_ajax'),
|
||||
path('new_msg_to_user/', new_msg_to_user_ajax, name='new_msg_to_user' ),
|
||||
|
||||
@@ -6,5 +6,7 @@ from .js_views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('create_route/', create_route_ajax, name='create_route_ajax'),
|
||||
path('edit_route/', edit_route_ajax, name='edit_route_ajax'),
|
||||
|
||||
path('get_routes/', get_routes_ajax, name='get_routes_ajax'),
|
||||
]
|
||||
@@ -17,6 +17,37 @@ from .forms import *
|
||||
from .funcs import get_routes_for_user
|
||||
|
||||
|
||||
def edit_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
data = request.POST
|
||||
|
||||
Dict = {}
|
||||
|
||||
try:
|
||||
|
||||
if not 'route_id' in data:
|
||||
msg = f'Недостаточно данных'
|
||||
return {'errors': msg}
|
||||
|
||||
route = Route.objects.get(data['route_id'])
|
||||
|
||||
form = CreateRouteForm(route)
|
||||
|
||||
Dict = {
|
||||
'form': form
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
# form.errors.append({'__all__': f'Ошибка: {str(e)}'})
|
||||
print(str(e))
|
||||
|
||||
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
|
||||
def new_route_view_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
Reference in New Issue
Block a user