mirror of
https://github.com/task-17-lct/backend.git
synced 2024-11-24 03:33:44 +03:00
added regions endpoint
This commit is contained in:
parent
67260adb55
commit
eb319e01e9
|
@ -1,6 +1,6 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from passfinder.events.models import Hotel, HotelPhone, City, Event, BasePoint
|
from passfinder.events.models import Hotel, HotelPhone, City, Event, BasePoint, Region
|
||||||
|
|
||||||
|
|
||||||
class HotelPhoneSerializer(serializers.ModelSerializer):
|
class HotelPhoneSerializer(serializers.ModelSerializer):
|
||||||
|
@ -47,3 +47,9 @@ class RouteSerializer(serializers.Serializer):
|
||||||
name = serializers.CharField()
|
name = serializers.CharField()
|
||||||
description = serializers.CharField()
|
description = serializers.CharField()
|
||||||
points = serializers.ListSerializer(child=PointSerializer())
|
points = serializers.ListSerializer(child=PointSerializer())
|
||||||
|
|
||||||
|
|
||||||
|
class RegionSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Region
|
||||||
|
fields = ["oid", "title", "description_short"]
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from passfinder.events.api.views import BuildRouteApiView
|
from passfinder.events.api.views import BuildRouteApiView, ListRegionApiView
|
||||||
|
|
||||||
app_name = "events"
|
app_name = "events"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("route/build", BuildRouteApiView.as_view(), name="build_route")
|
path("route/build", BuildRouteApiView.as_view(), name="build_route"),
|
||||||
|
path("regions", ListRegionApiView.as_view(), name="regions"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
from django_filters import DateFilter
|
from django_filters import DateFilter
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from rest_framework.generics import GenericAPIView
|
from rest_framework.generics import GenericAPIView, ListAPIView
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from passfinder.events.api.serializers import PointSerializer, RouteSerializer
|
from passfinder.events.api.serializers import (
|
||||||
from passfinder.events.models import BasePoint
|
PointSerializer,
|
||||||
|
RouteSerializer,
|
||||||
|
RegionSerializer,
|
||||||
|
)
|
||||||
|
from passfinder.events.models import BasePoint, Region
|
||||||
|
|
||||||
|
|
||||||
class BuildRouteApiView(GenericAPIView):
|
class BuildRouteApiView(GenericAPIView):
|
||||||
|
@ -25,3 +29,8 @@ def get(self, request):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return Response(data=routes)
|
return Response(data=routes)
|
||||||
|
|
||||||
|
|
||||||
|
class ListRegionApiView(ListAPIView):
|
||||||
|
serializer_class = RegionSerializer
|
||||||
|
queryset = Region.objects.all()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user