2023-05-21 20:46:07 +03:00
|
|
|
from django_filters import DateFilter
|
|
|
|
from django_filters.rest_framework import DjangoFilterBackend
|
2023-05-23 00:33:04 +03:00
|
|
|
from rest_framework.generics import GenericAPIView, ListAPIView
|
2023-05-21 20:46:07 +03:00
|
|
|
from rest_framework.response import Response
|
|
|
|
|
2023-05-23 00:33:04 +03:00
|
|
|
from passfinder.events.api.serializers import (
|
|
|
|
PointSerializer,
|
|
|
|
RouteSerializer,
|
|
|
|
RegionSerializer,
|
|
|
|
)
|
|
|
|
from passfinder.events.models import BasePoint, Region
|
2023-05-21 20:46:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
class BuildRouteApiView(GenericAPIView):
|
|
|
|
filter_backends = (DjangoFilterBackend,)
|
|
|
|
filterset_class = DateFilter
|
2023-05-22 22:29:46 +03:00
|
|
|
serializer_class = RouteSerializer
|
2023-05-21 20:46:07 +03:00
|
|
|
|
|
|
|
def get(self, request):
|
2023-05-22 22:29:46 +03:00
|
|
|
routes = []
|
|
|
|
for _ in range(10):
|
|
|
|
routes.append(
|
|
|
|
{
|
|
|
|
"name": "bebra",
|
|
|
|
"description": "bebra bebra bebra",
|
|
|
|
"points": PointSerializer(many=True).to_representation(
|
|
|
|
BasePoint.objects.order_by("?")[:10]
|
|
|
|
),
|
|
|
|
}
|
2023-05-21 20:46:07 +03:00
|
|
|
)
|
2023-05-22 22:29:46 +03:00
|
|
|
return Response(data=routes)
|
2023-05-23 00:33:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ListRegionApiView(ListAPIView):
|
|
|
|
serializer_class = RegionSerializer
|
|
|
|
queryset = Region.objects.all()
|