Better pass-midnight management

This commit is contained in:
2024-01-27 11:43:01 +01:00
parent 1192e89a01
commit 8619553a30
6 changed files with 37 additions and 38 deletions

View File

@ -1,4 +1,4 @@
from datetime import date, datetime, time
from datetime import date, datetime, time, timedelta
from django.db.models import Q
from django.views.generic import TemplateView
@ -11,7 +11,7 @@ class GareView(TemplateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
stop = Stop.objects.get(name__iexact=kwargs["gare"], location_type=1)
stop = Stop.objects.filter(name__iexact=kwargs["gare"], location_type=1).first()
context['stop'] = stop
next_departures = []
@ -27,6 +27,9 @@ class GareView(TemplateView):
context['query_date'] = query_date
context['query_time'] = query_time
query_time = query_time.isoformat(timespec='seconds')
query_time = timedelta(seconds=int(query_time[:2]) * 3600 + int(query_time[3:5]) * 60 + int(query_time[6:]))
qs = StopTime.objects.none()
for child in Stop.objects.filter(name__iexact=kwargs["gare"], location_type=0).all():
qs_child = StopTime.objects.filter(stop=child, pickup_type=0, departure_time__gte=query_time)