2.1.34 route_search_results_View fix cities
This commit is contained in:
@@ -8,6 +8,7 @@ from BaseModels.print_funcs import print_ext
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_and_set_lang(request):
|
def get_and_set_lang(request):
|
||||||
from django.utils.translation import activate, get_language
|
from django.utils.translation import activate, get_language
|
||||||
lang = None
|
lang = None
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ def generate_routes(request, routes_count):
|
|||||||
):
|
):
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from RoutesApp.funcs import get_city_by_type_transport_and_address_point
|
|
||||||
from RoutesApp.models import Route
|
from RoutesApp.models import Route
|
||||||
from ReferenceDataApp.models import Airport, City
|
from ReferenceDataApp.models import Airport, City
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,13 @@ from timezonefinder import TimezoneFinder
|
|||||||
|
|
||||||
tzf = TimezoneFinder()
|
tzf = TimezoneFinder()
|
||||||
|
|
||||||
|
def get_city_by_id(city_id):
|
||||||
|
try:
|
||||||
|
return City.objects.get(id=city_id)
|
||||||
|
except City.DoesNotExist:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def search_cities_in_db(search_str):
|
def search_cities_in_db(search_str):
|
||||||
res_data = []
|
res_data = []
|
||||||
Q_obj = Q(name_en__icontains=search_str) | Q(name_ru__icontains=search_str) | \
|
Q_obj = Q(name_en__icontains=search_str) | Q(name_ru__icontains=search_str) | \
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from uuid import uuid1
|
from uuid import uuid1
|
||||||
|
|
||||||
|
from ReferenceDataApp.funcs import get_city_by_id
|
||||||
from .models import *
|
from .models import *
|
||||||
from django.contrib import auth
|
from django.contrib import auth
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse, Http404
|
||||||
@@ -39,17 +41,23 @@ def route_search_results_View(request):
|
|||||||
'page_type': 'routes',
|
'page_type': 'routes',
|
||||||
'next_page_els_count': routes_Dict['next_page_els_count'],
|
'next_page_els_count': routes_Dict['next_page_els_count'],
|
||||||
}
|
}
|
||||||
if 'from_address_point_txt' in routes_Dict:
|
|
||||||
data.update({'from_address_point_txt': routes_Dict['from_address_point_txt']})
|
from_city = None
|
||||||
if 'to_address_point_txt' in routes_Dict:
|
to_city = None
|
||||||
data.update({'to_address_point_txt': routes_Dict['to_address_point_txt']})
|
if 'from_city' in data and data['from_city']:
|
||||||
|
from_city = get_city_by_id(data['from_city'])
|
||||||
|
data.update({'from_city': from_city})
|
||||||
|
if 'to_city' in data and data['to_city']:
|
||||||
|
to_city = get_city_by_id(data['to_city'])
|
||||||
|
data.update({'to_city': to_city})
|
||||||
|
|
||||||
Dict.update({'route_form': RouteForm(initial=data, owner_type=owner_type)})
|
Dict.update({'route_form': RouteForm(initial=data, owner_type=owner_type)})
|
||||||
|
|
||||||
title = _('Результат поиска маршрутов')
|
title = _('Результат поиска маршрутов')
|
||||||
if 'from_address_point_txt' in data:
|
if from_city:
|
||||||
title = f'{title} из {data["from_address_point_txt"]}'
|
title = f'{title} из {from_city.name}'
|
||||||
if 'to_address_point_txt' in data:
|
if to_city:
|
||||||
title = f'{title} в {data["to_address_point_txt"]}'
|
title = f'{title} в {to_city.name}'
|
||||||
|
|
||||||
Dict.update({
|
Dict.update({
|
||||||
'page': {
|
'page': {
|
||||||
|
|||||||
Reference in New Issue
Block a user