edit route url
This commit is contained in:
SDE
2023-07-31 19:16:09 +03:00
parent 583bcfc9a8
commit dce31b11b7
3 changed files with 35 additions and 0 deletions

View File

@@ -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' ),

View File

@@ -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'),
]

View File

@@ -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