get routes
This commit is contained in:
SDE
2023-07-26 16:22:26 +03:00
parent 9c58c20c31
commit 5688746e4f

View File

@@ -39,17 +39,22 @@ def get_routes_ajax(request):
for route in routes:
if route.type_transport == 'avia':
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)
try:
route.from_country = route.from_city.country
route.to_country = route.from_city.country
if route.type_transport == 'avia':
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 = {
'routes': routes
@@ -69,8 +74,7 @@ def get_routes_ajax(request):
'all__': f'ошибка в запросе = {str(e)}'
}
}
html = render_to_string('blocks/profile/b_new_route.html', errors_Dict, request=request)
return JsonResponse({'html': html}, status=400)
return JsonResponse(errors_Dict, status=400)