mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Review roster API
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from rest_framework.generics import ListAPIView, RetrieveAPIView
|
||||
from rest_framework.schemas.openapi import AutoSchema
|
||||
|
||||
from roster.models import RollingStock
|
||||
from roster.serializers import RollingStockSerializer
|
||||
@@ -14,14 +15,30 @@ class RosterGet(RetrieveAPIView):
|
||||
serializer_class = RollingStockSerializer
|
||||
lookup_field = "uuid"
|
||||
|
||||
schema = AutoSchema(
|
||||
operation_id_base="retrieveRollingStockByUUID"
|
||||
)
|
||||
|
||||
|
||||
class RosterAddress(ListAPIView):
|
||||
queryset = RollingStock.objects.all()
|
||||
serializer_class = RollingStockSerializer
|
||||
lookup_field = "address"
|
||||
|
||||
schema = AutoSchema(
|
||||
operation_id_base="retrieveRollingStockByAddress"
|
||||
)
|
||||
|
||||
def get_queryset(self):
|
||||
address = self.kwargs["address"]
|
||||
return RollingStock.objects.filter(address=address)
|
||||
|
||||
|
||||
class RosterIdentifier(RetrieveAPIView):
|
||||
queryset = RollingStock.objects.all()
|
||||
class RosterClass(ListAPIView):
|
||||
serializer_class = RollingStockSerializer
|
||||
lookup_field = "identifier"
|
||||
|
||||
schema = AutoSchema(
|
||||
operation_id_base="retrieveRollingStockByClass"
|
||||
)
|
||||
|
||||
def get_queryset(self):
|
||||
_class = self.kwargs["class"]
|
||||
return RollingStock.objects.filter(rolling_class__identifier=_class)
|
||||
|
Reference in New Issue
Block a user