From e03f4a015ab1675b7368f8ff4ef51703efbcbb16 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 12 Nov 2024 14:06:58 +0300 Subject: [PATCH 1/2] 1.7.18 generate routes --- GeneralApp/urls.py | 1 + GeneralApp/views.py | 61 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/GeneralApp/urls.py b/GeneralApp/urls.py index 93dc521..0066e4e 100644 --- a/GeneralApp/urls.py +++ b/GeneralApp/urls.py @@ -8,4 +8,5 @@ urlpatterns = [ path('', MainPage, name='main'), path('page//', StaticPageView, name='static_page'), path('test_code', test_code, name='test_code'), + path('generate_routes//', generate_routes, name='generate_routes'), ] \ No newline at end of file diff --git a/GeneralApp/views.py b/GeneralApp/views.py index 0fd41a0..590e6e3 100644 --- a/GeneralApp/views.py +++ b/GeneralApp/views.py @@ -16,6 +16,65 @@ 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) + ] + + # routes = [ + # Route( + # type_transport='avia', + # departure_DT=datetime(year=2024, month=9, day=1), + # arrival_DT=datetime(year=2024, month=9, day=3), + # from_address_point = from_air.id, + # to_address_point = to_air.id, + # from_city = from_air.city, + # to_city = to_air.city, + # weight = item, + # phone = '1234567890', + # owner = request.user + # ) for item in range(1000) + # ] + + 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 +84,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)) From a329720f1c7a2f44db86a595338760eeab8d10a8 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 12 Nov 2024 16:04:12 +0300 Subject: [PATCH 2/2] 1.7.18 w_carrier_card.html fix route.highlight_end_DT --- GeneralApp/views.py | 15 --------------- RoutesApp/admin.py | 5 ++++- templates/widgets/w_carrier_card.html | 2 +- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/GeneralApp/views.py b/GeneralApp/views.py index 590e6e3..3c1efef 100644 --- a/GeneralApp/views.py +++ b/GeneralApp/views.py @@ -48,21 +48,6 @@ def generate_routes(request, routes_count): ) for item in range(routes_count) ] - # routes = [ - # Route( - # type_transport='avia', - # departure_DT=datetime(year=2024, month=9, day=1), - # arrival_DT=datetime(year=2024, month=9, day=3), - # from_address_point = from_air.id, - # to_address_point = to_air.id, - # from_city = from_air.city, - # to_city = to_air.city, - # weight = item, - # phone = '1234567890', - # owner = request.user - # ) for item in range(1000) - # ] - Route.objects.bulk_create(routes) if res: diff --git a/RoutesApp/admin.py b/RoutesApp/admin.py index 07e0814..3a45d44 100644 --- a/RoutesApp/admin.py +++ b/RoutesApp/admin.py @@ -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', diff --git a/templates/widgets/w_carrier_card.html b/templates/widgets/w_carrier_card.html index 84af8be..7a13392 100644 --- a/templates/widgets/w_carrier_card.html +++ b/templates/widgets/w_carrier_card.html @@ -11,7 +11,7 @@ {% if current_datetime|date:"Y-m-d H:i:s" > departure_datetime|date:"Y-m-d H:i:s" %}
{% else %} -
+
current_datetime|date:"Y-m-d H:i:s" %} highlight-color {% endif %}" data-number-of-route="{{ route.id }}"> {% endif %} {% endwith %} {% endwith %}