77 lines
2.3 KiB
Python
77 lines
2.3 KiB
Python
from django.shortcuts import render
|
|
|
|
from uuid import uuid1
|
|
|
|
from ReferenceDataApp.funcs import get_city_by_id
|
|
from .models import *
|
|
from django.contrib import auth
|
|
from django.http import HttpResponse, Http404
|
|
from django.template import loader, RequestContext
|
|
from django.contrib.auth.decorators import login_required
|
|
from BaseModels.mailSender import techSendMail
|
|
from django.utils.translation import gettext as _
|
|
from datetime import datetime
|
|
from .funcs import *
|
|
from .forms import *
|
|
from GeneralApp.funcs import get_inter_http_response
|
|
|
|
|
|
|
|
|
|
def route_search_results_View(request):
|
|
|
|
Dict = {}
|
|
data = {}
|
|
|
|
try:
|
|
|
|
if request.GET:
|
|
data = request.GET.dict()
|
|
|
|
owner_type = data['owner_type']
|
|
|
|
routes_Dict = get_routes_Dict(data=data)
|
|
if routes_Dict:
|
|
Dict = {
|
|
'routes': routes_Dict['routes'],
|
|
'last_block': routes_Dict['last_block'],
|
|
'show_filter_and_results': True,
|
|
'owner_type': owner_type,
|
|
'last_el': routes_Dict['last_el'],
|
|
'page_type': 'routes',
|
|
'next_page_els_count': routes_Dict['next_page_els_count'],
|
|
}
|
|
|
|
from_city = None
|
|
to_city = None
|
|
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)})
|
|
|
|
title = _('Результат поиска маршрутов')
|
|
if from_city:
|
|
title = f'{title} из {from_city.name}'
|
|
if to_city:
|
|
title = f'{title} в {to_city.name}'
|
|
|
|
Dict.update({
|
|
'page': {
|
|
'title': title,
|
|
'description': title,
|
|
'keywords': title,
|
|
}
|
|
})
|
|
|
|
t = loader.get_template('v2/pages/p_search_route_results.html')
|
|
return get_inter_http_response(t, Dict, request)
|
|
|
|
except Exception as e:
|
|
msg = f'!!! --- route_search_results_View Exception {str(e)}'
|
|
print(msg)
|
|
raise Http404
|