0.0.46
get routes
This commit is contained in:
@@ -39,17 +39,22 @@ def get_routes_ajax(request):
|
|||||||
|
|
||||||
for route in routes:
|
for route in routes:
|
||||||
|
|
||||||
if route.type_transport == 'avia':
|
try:
|
||||||
route.from_airport = Airport.objects.get(id=route.from_address_point)
|
|
||||||
route.to_airport = Airport.objects.get(id=route.to_address_point)
|
|
||||||
route.from_city = route.from_airport.city
|
|
||||||
route.to_city = route.to_airport.city
|
|
||||||
else:
|
|
||||||
route.from_city = City.objects.get(id=route.from_address_point)
|
|
||||||
route.to_city = City.objects.get(id=route.to_address_point)
|
|
||||||
|
|
||||||
route.from_country = route.from_city.country
|
if route.type_transport == 'avia':
|
||||||
route.to_country = route.from_city.country
|
route.from_airport = Airport.objects.get(id=route.from_address_point)
|
||||||
|
route.to_airport = Airport.objects.get(id=route.to_address_point)
|
||||||
|
route.from_city = route.from_airport.city
|
||||||
|
route.to_city = route.to_airport.city
|
||||||
|
else:
|
||||||
|
route.from_city = City.objects.get(id=route.from_address_point)
|
||||||
|
route.to_city = City.objects.get(id=route.to_address_point)
|
||||||
|
|
||||||
|
route.from_country = route.from_city.country
|
||||||
|
route.to_country = route.from_city.country
|
||||||
|
except Exception as e:
|
||||||
|
msg = f'get route points = {str(e)}'
|
||||||
|
print(msg)
|
||||||
|
|
||||||
Dict = {
|
Dict = {
|
||||||
'routes': routes
|
'routes': routes
|
||||||
@@ -69,8 +74,7 @@ def get_routes_ajax(request):
|
|||||||
'all__': f'ошибка в запросе = {str(e)}'
|
'all__': f'ошибка в запросе = {str(e)}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
html = render_to_string('blocks/profile/b_new_route.html', errors_Dict, request=request)
|
return JsonResponse(errors_Dict, status=400)
|
||||||
return JsonResponse({'html': html}, status=400)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user