1.1.9 funcs for raise and highlight routes
This commit is contained in:
@@ -19,6 +19,72 @@ from GeneralApp.funcs import get_and_set_lang
|
||||
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)
|
||||
|
||||
if not data or not 'route_id' in data:
|
||||
msg = _('Недостаточно данных')
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
try:
|
||||
route = Route.objects.get(owner=request.user, id=data['route_id'])
|
||||
except Route.DoesNotExist:
|
||||
msg = _('Не найден маршрут')
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
if not route.get_permission_for_raise():
|
||||
msg = _('Нет доступа к выделению')
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
route.highlight_color = '#FF0000'
|
||||
route.save(update_fields=['highlight_color'])
|
||||
|
||||
Dict = {
|
||||
'route': route,
|
||||
}
|
||||
|
||||
html = render_to_string('widgets/routes/w_my_route.html', Dict, request=request)
|
||||
|
||||
res_Dict = {
|
||||
'html': html
|
||||
}
|
||||
|
||||
return JsonResponse(res_Dict)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
if not data or not 'route_id' in data:
|
||||
msg = _('Недостаточно данных')
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
try:
|
||||
route = Route.objects.get(owner=request.user, id=data['route_id'])
|
||||
except Route.DoesNotExist:
|
||||
msg = _('Не найден маршрут')
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
if not route.get_permission_for_raise():
|
||||
msg = _('Нет доступных поднятий')
|
||||
return JsonResponse({'errors': msg})
|
||||
|
||||
route.rising_DT = datetime.now()
|
||||
route.save(update_fields=['rising_DT'])
|
||||
|
||||
return JsonResponse({'status': 'ok'})
|
||||
|
||||
|
||||
def del_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
Reference in New Issue
Block a user