0.7.24
del route
This commit is contained in:
@@ -9,6 +9,7 @@ urlpatterns = [
|
||||
path('create_or_change_route/', create_or_change_route_ajax, name='create_or_change_route_ajax'),
|
||||
|
||||
path('edit_route/', edit_route_ajax, name='edit_route_ajax'),
|
||||
path('del_route/', del_route_ajax, name='del_route_ajax'),
|
||||
|
||||
path('get_routes/', get_my_routes_ajax, name='get_my_routes_ajax'),
|
||||
path('find_routes/', find_routes_ajax, name='find_routes_ajax'),
|
||||
|
||||
@@ -17,6 +17,39 @@ from .forms import *
|
||||
from .funcs import *
|
||||
|
||||
|
||||
def del_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
if not 'route_id' in data:
|
||||
msg = f'Недостаточно данных'
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
route = Route.objects.filter(id=data['route_id']).delete()
|
||||
|
||||
routes_Dict = get_routes_Dict(request.user)
|
||||
if 'errors' in routes_Dict:
|
||||
return JsonResponse(routes_Dict, status=400)
|
||||
|
||||
html = render_to_string('blocks/profile/b_my_routes.html', routes_Dict, request=request)
|
||||
|
||||
res_Dict = {
|
||||
'html': html
|
||||
}
|
||||
|
||||
return JsonResponse(res_Dict)
|
||||
|
||||
except Exception as e:
|
||||
# form.errors.append({'__all__': f'Ошибка: {str(e)}'})
|
||||
msg = f'Ошибка del_route_ajax = {str(e)}'
|
||||
print(msg)
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
|
||||
|
||||
def edit_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
Reference in New Issue
Block a user