From cacd63e1757b0e5936951abf068965cefb732768 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 18 Oct 2021 02:30:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Get=20access=20serializer=20for?= =?UTF-8?q?=20list=20views?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/sophon/core/views.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/sophon/core/views.py b/backend/sophon/core/views.py index a21a741..cd14384 100644 --- a/backend/sophon/core/views.py +++ b/backend/sophon/core/views.py @@ -51,11 +51,9 @@ class ReadSophonViewSet(ReadOnlyModelViewSet, metaclass=abc.ABCMeta): return permissions.AllowAny, def get_serializer_class(self): - if self.action in ["list"]: - return self.get_queryset().model.get_view_serializer() - elif self.action in ["create", "metadata"]: + if self.action in ["create", "metadata"]: 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) else: return self.get_custom_serializer_classes()