0.6.2
fix routes models
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
from .models import *
|
||||
|
||||
|
||||
def get_city_by_type_transport_and_address_point(type_transport, address_point):
|
||||
from ReferenceDataApp.models import Airport, City
|
||||
|
||||
try:
|
||||
if type_transport == 'avia':
|
||||
return Airport.objects.get(id=address_point).city
|
||||
else:
|
||||
return City.objects.get(id=address_point)
|
||||
except Exception as e:
|
||||
msg = f'get_city_by_type_transport_and_address_point Error = {str(e)}, type_transport = {type_transport}, address_point = {address_point}'
|
||||
print(msg)
|
||||
return None
|
||||
|
||||
def get_routes_Dict(user=None, data=None):
|
||||
from ReferenceDataApp.models import Airport, Country, City
|
||||
|
||||
@@ -29,10 +44,16 @@ def get_routes_Dict(user=None, data=None):
|
||||
kwargs.update({f'{key}__lte': int(weight_list[1])})
|
||||
if key not in (
|
||||
'from_address_point_txt', 'to_address_point_txt', 'csrfmiddlewaretoken', 'sort', 'weight',
|
||||
'from_el', 'to_el'
|
||||
'from_el', 'to_el', 'from_address_point', 'to_address_point'
|
||||
):
|
||||
kwargs.update({key: val})
|
||||
|
||||
if key == 'from_address_point':
|
||||
kwargs.update({f'from_city__id': val})
|
||||
|
||||
if key == 'to_address_point':
|
||||
kwargs.update({f'to_city__id': val})
|
||||
|
||||
if key == 'from_el':
|
||||
from_el = int(val)
|
||||
if key == 'to_el':
|
||||
|
||||
Reference in New Issue
Block a user