Recreate station screen with ReactJS

This commit is contained in:
2024-01-28 20:06:55 +01:00
parent 0890460ba7
commit 6317c900ef
24 changed files with 18813 additions and 12 deletions

View File

@ -1,8 +1,9 @@
from datetime import datetime, timedelta, date
from django.db.models import F, Q, OuterRef, Subquery
from django.db.models import F, Q
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import viewsets
from rest_framework.filters import OrderingFilter
from sncf.api.serializers import AgencySerializer, StopSerializer, RouteSerializer, TripSerializer, \
StopTimeSerializer, CalendarSerializer, CalendarDateSerializer, TransferSerializer, \
@ -42,8 +43,10 @@ class TripViewSet(viewsets.ReadOnlyModelViewSet):
class StopTimeViewSet(viewsets.ReadOnlyModelViewSet):
queryset = StopTime.objects.order_by('id').all()
serializer_class = StopTimeSerializer
filter_backends = [DjangoFilterBackend]
filter_backends = [DjangoFilterBackend, OrderingFilter]
filterset_fields = '__all__'
ordering_fields = ['arrival_time', 'departure_time', 'stop_sequence',]
ordering = ['stop_sequence',]
class CalendarViewSet(viewsets.ReadOnlyModelViewSet):
@ -95,9 +98,10 @@ class NextDeparturesViewSet(viewsets.ReadOnlyModelViewSet):
if stop_id:
stop = Stop.objects.get(id=stop_id)
stops = Stop.objects.filter(Q(id=stop_id)
| Q(parent_station=stop_id)
| Q(parent_station=stop.parent_station_id)).values_list('id', flat=True)
stop_filter = Q(stop__in=stops)
| Q(parent_station=stop_id))
if stop.location_type == 0:
stops |= Stop.objects.filter(parent_station=stop.parent_station_id)
stop_filter = Q(stop__in=stops.values_list('id', flat=True))
elif stop_name:
stops = Stop.objects.filter(name__iexact=stop_name).values_list('id', flat=True)
stop_filter = Q(stop__in=stops)
@ -150,9 +154,10 @@ class NextArrivalsViewSet(viewsets.ReadOnlyModelViewSet):
if stop_id:
stop = Stop.objects.get(id=stop_id)
stops = Stop.objects.filter(Q(id=stop_id)
| Q(parent_station=stop_id)
| Q(parent_station=stop.parent_station_id)).values_list('id', flat=True)
stop_filter = Q(stop__in=stops)
| Q(parent_station=stop_id))
if stop.location_type == 0:
stops |= Stop.objects.filter(parent_station=stop.parent_station_id)
stop_filter = Q(stop__in=stops.values_list('id', flat=True))
elif stop_name:
stops = Stop.objects.filter(name__iexact=stop_name).values_list('id', flat=True)
stop_filter = Q(stop__in=stops)