1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 14:54:22 +00:00

🔧 Get access serializer for list views

This commit is contained in:
Steffo 2021-10-18 02:30:47 +02:00 committed by Stefano Pigozzi
parent b493a65e01
commit 2886c4598d

View file

@ -51,11 +51,9 @@ class ReadSophonViewSet(ReadOnlyModelViewSet, metaclass=abc.ABCMeta):
return permissions.AllowAny, return permissions.AllowAny,
def get_serializer_class(self): def get_serializer_class(self):
if self.action in ["list"]: if self.action in ["create", "metadata"]:
return self.get_queryset().model.get_view_serializer()
elif self.action in ["create", "metadata"]:
return self.get_queryset().model.get_creation_serializer() return self.get_queryset().model.get_creation_serializer()
elif self.action in ["retrieve", "update", "partial_update", "destroy"]: elif self.action in ["list", "retrieve", "update", "partial_update", "destroy"]:
return self.get_object().get_access_serializer(self.request.user) return self.get_object().get_access_serializer(self.request.user)
else: else:
return self.get_custom_serializer_classes() return self.get_custom_serializer_classes()