0.7.29
fix search routes insert txt address points
This commit is contained in:
@@ -54,6 +54,14 @@ class City(BaseModel):
|
|||||||
else:
|
else:
|
||||||
return f'{self.id}'
|
return f'{self.id}'
|
||||||
|
|
||||||
|
def get_country_n_city_str(self):
|
||||||
|
country = 'Неизвестно'
|
||||||
|
city = self.name
|
||||||
|
if self.country:
|
||||||
|
country = self.country
|
||||||
|
|
||||||
|
return f'{city} / {country}'
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Город')
|
verbose_name = _('Город')
|
||||||
|
|||||||
@@ -86,6 +86,11 @@ def get_profile_new_route_page_html(request, data):
|
|||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
|
def get_country_n_city_str_by_type_transport_and_address_point(type_transport, address_point):
|
||||||
|
city = get_city_by_type_transport_and_address_point(type_transport, address_point)
|
||||||
|
return city.get_country_n_city_str()
|
||||||
|
|
||||||
|
|
||||||
def get_city_by_type_transport_and_address_point(type_transport, address_point):
|
def get_city_by_type_transport_and_address_point(type_transport, address_point):
|
||||||
from ReferenceDataApp.models import Airport, City
|
from ReferenceDataApp.models import Airport, City
|
||||||
|
|
||||||
@@ -130,6 +135,8 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
from_el = None
|
from_el = None
|
||||||
to_el = None
|
to_el = None
|
||||||
|
|
||||||
|
res_Dict = {}
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
for key, val in data.items():
|
for key, val in data.items():
|
||||||
if val:
|
if val:
|
||||||
@@ -144,6 +151,7 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
items_list = val.split(',')
|
items_list = val.split(',')
|
||||||
kwargs.update({f'{key}__in': items_list})
|
kwargs.update({f'{key}__in': items_list})
|
||||||
|
|
||||||
|
|
||||||
if key in (
|
if key in (
|
||||||
'departure_DT', 'arrival_DT'
|
'departure_DT', 'arrival_DT'
|
||||||
):
|
):
|
||||||
@@ -158,9 +166,19 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
|
|
||||||
if key == 'from_address_point':
|
if key == 'from_address_point':
|
||||||
kwargs.update({f'from_city__id': val})
|
kwargs.update({f'from_city__id': val})
|
||||||
|
res_Dict.update({
|
||||||
|
'from_address_point_txt': get_country_n_city_str_by_type_transport_and_address_point(
|
||||||
|
'road', val
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
if key == 'to_address_point':
|
if key == 'to_address_point':
|
||||||
kwargs.update({f'to_city__id': val})
|
kwargs.update({f'to_city__id': val})
|
||||||
|
res_Dict.update({
|
||||||
|
'to_address_point_txt': get_country_n_city_str_by_type_transport_and_address_point(
|
||||||
|
'road', val
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
if key == 'from_el':
|
if key == 'from_el':
|
||||||
from_el = int(val)
|
from_el = int(val)
|
||||||
@@ -183,7 +201,7 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
if to_el and to_el >= routes_count:
|
if to_el and to_el >= routes_count:
|
||||||
last_block_routes = True
|
last_block_routes = True
|
||||||
|
|
||||||
res_Dict = {}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -206,10 +224,10 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
msg = f'get_routes_for_user get route Error = {str(e)}'
|
msg = f'get_routes_for_user get route Error = {str(e)}'
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
res_Dict = {
|
res_Dict.update({
|
||||||
'routes': routes,
|
'routes': routes,
|
||||||
'last_block_routes': last_block_routes
|
'last_block_routes': last_block_routes
|
||||||
}
|
})
|
||||||
return res_Dict
|
return res_Dict
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,26 +75,18 @@ class Route(BaseModel):
|
|||||||
ordering = ('name',)
|
ordering = ('name',)
|
||||||
|
|
||||||
def from_country_n_city_str(self):
|
def from_country_n_city_str(self):
|
||||||
country = 'Неизвестно'
|
res = 'Неизвестно'
|
||||||
if self.from_city:
|
if self.from_city:
|
||||||
city = self.from_city.name
|
res = self.from_city.get_country_n_city_str()
|
||||||
if self.from_city.country:
|
|
||||||
country = self.from_city.country
|
|
||||||
else:
|
|
||||||
city = 'Неизвестно'
|
|
||||||
|
|
||||||
return f'{city} / {country}'
|
return res
|
||||||
|
|
||||||
def to_country_n_city_str(self):
|
def to_country_n_city_str(self):
|
||||||
country = 'Неизвестно'
|
res = 'Неизвестно'
|
||||||
if self.to_city:
|
if self.to_city:
|
||||||
city = self.to_city.name
|
res = self.to_city.get_country_n_city_str()
|
||||||
if self.to_city.country:
|
|
||||||
country = self.to_city.country
|
|
||||||
else:
|
|
||||||
city = 'Неизвестно'
|
|
||||||
|
|
||||||
return f'{city} / {country}'
|
return res
|
||||||
|
|
||||||
|
|
||||||
def get_address_points(self):
|
def get_address_points(self):
|
||||||
|
|||||||
@@ -28,11 +28,15 @@ def route_search_results_View(request):
|
|||||||
if routes_Dict:
|
if routes_Dict:
|
||||||
Dict = {
|
Dict = {
|
||||||
'routes': routes_Dict['routes'],
|
'routes': routes_Dict['routes'],
|
||||||
'route_form': RouteForm(initial=data),
|
|
||||||
'last_block_routes': routes_Dict['last_block_routes'],
|
'last_block_routes': routes_Dict['last_block_routes'],
|
||||||
'show_filter_and_results': True,
|
'show_filter_and_results': True,
|
||||||
'owner_type': data['owner_type']
|
'owner_type': data['owner_type']
|
||||||
}
|
}
|
||||||
|
if 'from_address_point_txt' in routes_Dict:
|
||||||
|
data.update({'from_address_point_txt': routes_Dict['from_address_point_txt']})
|
||||||
|
if 'to_address_point_txt' in routes_Dict:
|
||||||
|
data.update({'to_address_point_txt': routes_Dict['to_address_point_txt']})
|
||||||
|
Dict.update({'route_form': RouteForm(initial=data)})
|
||||||
|
|
||||||
t = loader.get_template('pages/p_results_find_route.html')
|
t = loader.get_template('pages/p_results_find_route.html')
|
||||||
return HttpResponse(t.render(Dict, request))
|
return HttpResponse(t.render(Dict, request))
|
||||||
|
|||||||
Reference in New Issue
Block a user