Add a custom manager to filter private and unpublished stuff (#39)

* Implement a customer manager for flatpages

* Implement public manager for private objects

* Add support for unpublished objects in roster and consist

* Add support for unpublished objects in bookshelf

* Update filtering on REST views

* Use uuid in urls.py

* Increment version
This commit is contained in:
2024-11-04 15:00:34 +01:00
committed by GitHub
parent 61b6d7a84e
commit 1c07c6a7a9
22 changed files with 297 additions and 154 deletions

View File

@@ -6,26 +6,30 @@ from roster.serializers import RollingStockSerializer
class RosterList(ListAPIView):
queryset = RollingStock.objects.all()
serializer_class = RollingStockSerializer
def get_queryset(self):
return RollingStock.objects.get_published(self.request.user)
class RosterGet(RetrieveAPIView):
queryset = RollingStock.objects.all()
serializer_class = RollingStockSerializer
lookup_field = "uuid"
schema = AutoSchema(operation_id_base="retrieveRollingStockByUUID")
def get_queryset(self):
return RollingStock.objects.get_published(self.request.user)
class RosterAddress(ListAPIView):
serializer_class = RollingStockSerializer
schema = AutoSchema(operation_id_base="retrieveRollingStockByAddress")
def get_queryset(self):
address = self.kwargs["address"]
return RollingStock.objects.filter(address=address)
return RollingStock.objects.get_published(self.request.user).filter(
address=address
)
class RosterClass(ListAPIView):
@@ -35,4 +39,6 @@ class RosterClass(ListAPIView):
def get_queryset(self):
_class = self.kwargs["class"]
return RollingStock.objects.filter(rolling_class__identifier=_class)
return RollingStock.objects.get_published(self.request.user).filter(
rolling_class__identifier=_class
)