0.4.3
routes filter
This commit is contained in:
@@ -11,5 +11,6 @@ urlpatterns = [
|
||||
path('edit_route/', edit_route_ajax, name='edit_route_ajax'),
|
||||
|
||||
path('get_routes/', get_routes_ajax, name='get_routes_ajax'),
|
||||
path('find_routes/', find_routes_ajax, name='find_routes_ajax'),
|
||||
|
||||
]
|
||||
@@ -146,6 +146,40 @@ def new_route_view_ajax(request):
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
|
||||
def find_routes_ajax(request):
|
||||
|
||||
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST
|
||||
|
||||
routes_Dict = get_routes_Dict(data=data)
|
||||
if 'errors' in routes_Dict:
|
||||
return JsonResponse(routes_Dict, status=400)
|
||||
|
||||
|
||||
html = render_to_string('blocks/b_search_routes.html', routes_Dict, request=request)
|
||||
|
||||
res_Dict = {
|
||||
'html': html,
|
||||
# 'form': RouteForm(initial=data)
|
||||
}
|
||||
|
||||
return JsonResponse(res_Dict)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
errors_Dict = {
|
||||
'errors': {
|
||||
'all__': f'ошибка в запросе = {str(e)}'
|
||||
}
|
||||
}
|
||||
return JsonResponse(errors_Dict, status=400)
|
||||
|
||||
|
||||
def get_routes_ajax(request):
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user