@@ -8,4 +8,5 @@ urlpatterns = [
|
||||
path('', MainPage, name='main'),
|
||||
path('page/<str:url>/', StaticPageView, name='static_page'),
|
||||
path('test_code', test_code, name='test_code'),
|
||||
path('generate_routes/<int:routes_count>/', generate_routes, name='generate_routes'),
|
||||
]
|
||||
@@ -16,6 +16,50 @@ from webpush import send_user_notification
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def generate_routes(request, routes_count):
|
||||
if (not request.user
|
||||
or not request.user.is_active
|
||||
or not request.user.is_authenticated
|
||||
or not request.user.is_staff
|
||||
):
|
||||
raise Http404
|
||||
|
||||
from RoutesApp.funcs import get_city_by_type_transport_and_address_point
|
||||
from RoutesApp.models import Route
|
||||
from ReferenceDataApp.models import Airport, City
|
||||
|
||||
res = None
|
||||
|
||||
from_air = Airport.objects.get(iata_code='MSQ')
|
||||
to_air = Airport.objects.get(iata_code='SVO')
|
||||
|
||||
routes = [
|
||||
Route(
|
||||
type_transport='road',
|
||||
departure_DT=datetime.now() + timedelta(days=7),
|
||||
arrival_DT=datetime.now() + timedelta(days=8),
|
||||
from_address_point=to_air.city.id,
|
||||
to_address_point=from_air.city.id,
|
||||
from_city=to_air.city,
|
||||
to_city=from_air.city,
|
||||
weight=item,
|
||||
phone='0987654321',
|
||||
owner=request.user
|
||||
) for item in range(routes_count)
|
||||
]
|
||||
|
||||
Route.objects.bulk_create(routes)
|
||||
|
||||
if res:
|
||||
if type(res) == str:
|
||||
return HttpResponse(res)
|
||||
else:
|
||||
return res
|
||||
|
||||
return HttpResponse('finished')
|
||||
|
||||
|
||||
|
||||
def test_code(request):
|
||||
|
||||
if (not request.user
|
||||
@@ -25,6 +69,8 @@ def test_code(request):
|
||||
):
|
||||
raise Http404
|
||||
|
||||
res = ''
|
||||
|
||||
from RoutesApp.search_matches import search_matches
|
||||
from RoutesApp.models import Route
|
||||
search_matches(Route.objects.filter(from_city__id=57062))
|
||||
|
||||
@@ -3,7 +3,10 @@ from .models import *
|
||||
from django.contrib import admin
|
||||
|
||||
class Admin_Route(Admin_Trans_BaseModel):
|
||||
readonly_fields = ['highlight_end_DT', 'rising_DT']
|
||||
readonly_fields = [
|
||||
# 'highlight_end_DT',
|
||||
'rising_DT'
|
||||
]
|
||||
list_display = [
|
||||
'id', 'owner_type',
|
||||
'rising_DT',
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{% if current_datetime|date:"Y-m-d H:i:s" > departure_datetime|date:"Y-m-d H:i:s" %}
|
||||
<div class="carrier-card out_of_date" data-number-of-route="{{ route.id }}">
|
||||
{% else %}
|
||||
<div class="carrier-card {% if route.highlight_color %} highlight-color {% endif %}" data-number-of-route="{{ route.id }}">
|
||||
<div class="carrier-card {% if route.highlight_color and route.highlight_end_DT|date:"Y-m-d H:i:s" > current_datetime|date:"Y-m-d H:i:s" %} highlight-color {% endif %}" data-number-of-route="{{ route.id }}">
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
Reference in New Issue
Block a user