Merge remote-tracking branch 'origin/v2' into v2
This commit is contained in:
@@ -21,31 +21,30 @@ from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from .forms import *
|
||||
from .funcs import *
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
from GeneralApp.funcs import get_and_set_lang, check_post_request_and_get_data
|
||||
from SubscribesApp.funcs import check_option_in_cur_user_subscribe
|
||||
|
||||
|
||||
def highlight_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
data = request.POST
|
||||
if not data and request.body:
|
||||
data = json.loads(request.body)
|
||||
data = check_post_request_and_get_data(request)
|
||||
if data == None:
|
||||
return Http404
|
||||
elif type(data) == str:
|
||||
return JsonResponse({'error': data}, status=400)
|
||||
|
||||
if not data or not 'route_id' in data:
|
||||
msg = _('Недостаточно данных')
|
||||
return JsonResponse({'errors': msg})
|
||||
return JsonResponse({'errors': msg}, status=400)
|
||||
|
||||
try:
|
||||
route = Route.objects.get(owner=request.user, id=data['route_id'])
|
||||
except Route.DoesNotExist:
|
||||
msg = _('Не найден маршрут')
|
||||
return JsonResponse({'errors': msg})
|
||||
return JsonResponse({'errors': msg}, status=400)
|
||||
|
||||
if not route.get_permission_for_highlight():
|
||||
msg = _('Нет доступа к выделению')
|
||||
return JsonResponse({'errors': msg})
|
||||
return JsonResponse({'errors': msg}, status=403)
|
||||
|
||||
|
||||
from SubscribesApp.funcs import get_cur_user_subscribe
|
||||
@@ -78,12 +77,11 @@ def highlight_route_ajax(request):
|
||||
|
||||
|
||||
def raise_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
data = request.POST
|
||||
if not data and request.body:
|
||||
data = json.loads(request.body)
|
||||
data = check_post_request_and_get_data(request)
|
||||
if data == None:
|
||||
return Http404
|
||||
elif type(data) == str:
|
||||
return JsonResponse({'error': data}, status=400)
|
||||
|
||||
if not data or not 'route_id' in data:
|
||||
msg = _('Недостаточно данных')
|
||||
@@ -97,7 +95,7 @@ def raise_route_ajax(request):
|
||||
|
||||
if not route.get_permission_for_raise():
|
||||
msg = _('Нет доступных поднятий')
|
||||
return JsonResponse({'errors': msg}, status=400)
|
||||
return JsonResponse({'errors': msg}, status=403)
|
||||
|
||||
route.rising_DT = datetime.now()
|
||||
route.save(update_fields=['rising_DT'])
|
||||
@@ -116,8 +114,11 @@ def raise_route_ajax(request):
|
||||
|
||||
|
||||
def del_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
data = check_post_request_and_get_data(request)
|
||||
if data == None:
|
||||
return Http404
|
||||
elif type(data) == str:
|
||||
return JsonResponse({'error': data}, status=400)
|
||||
|
||||
if not check_option_in_cur_user_subscribe(request.user, 'размещение заявок'):
|
||||
return JsonResponse({'html': 'нет доступа'}, status=403)
|
||||
@@ -126,7 +127,7 @@ def del_route_ajax(request):
|
||||
|
||||
try:
|
||||
|
||||
data = json.loads(request.body)
|
||||
# data = json.loads(request.body)
|
||||
if not 'route_id' in data:
|
||||
msg = f'Недостаточно данных'
|
||||
return JsonResponse({'errors': msg})
|
||||
@@ -156,15 +157,18 @@ def del_route_ajax(request):
|
||||
|
||||
|
||||
def edit_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
data = check_post_request_and_get_data(request)
|
||||
if data == None:
|
||||
return Http404
|
||||
elif type(data) == str:
|
||||
return JsonResponse({'error': data}, status=400)
|
||||
|
||||
if not check_option_in_cur_user_subscribe(request.user, 'размещение заявок'):
|
||||
return JsonResponse({'html': 'нет доступа'}, status=403)
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
data = json.loads(request.body)
|
||||
# data = json.loads(request.body)
|
||||
|
||||
Dict = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user