mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 06:44:21 +00:00
🐛 Fix NoneSerializer being used in actions
This commit is contained in:
parent
7c8dd8383c
commit
8df2394523
2 changed files with 13 additions and 1 deletions
|
@ -207,6 +207,12 @@ class ResearchGroupViewSet(WriteSophonViewSet):
|
|||
"owner": self.request.user,
|
||||
}
|
||||
|
||||
def get_custom_serializer_classes(self):
|
||||
if self.action in ["join", "leave"]:
|
||||
return self.get_object().get_access_serializer(self.request.user)
|
||||
else:
|
||||
return serializers.NoneSerializer
|
||||
|
||||
@action(detail=True, methods=["post"], name="Join group")
|
||||
def join(self, request, pk) -> Response:
|
||||
group = models.ResearchGroup.objects.get(pk=pk)
|
||||
|
|
|
@ -8,7 +8,7 @@ from rest_framework.request import Request
|
|||
from rest_framework.response import Response
|
||||
|
||||
from sophon.core.models import ResearchGroup
|
||||
from sophon.core.serializers import dynamic_serializer
|
||||
from sophon.core.serializers import dynamic_serializer, NoneSerializer
|
||||
from sophon.core.views import SophonGroupViewSet
|
||||
from sophon.notebooks.models import Notebook
|
||||
from sophon.projects.models import ResearchProject
|
||||
|
@ -18,6 +18,12 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
|
|||
def get_group_from_serializer(self, serializer) -> ResearchGroup:
|
||||
return serializer.validated_data["project"].group
|
||||
|
||||
def get_custom_serializer_classes(self):
|
||||
if self.action in ["sync", "start", "lock", "unlock", "stop"]:
|
||||
return self.get_object().get_access_serializer(self.request.user)
|
||||
else:
|
||||
return NoneSerializer
|
||||
|
||||
@action(["PATCH"], detail=True)
|
||||
def sync(self, request: Request, **kwargs):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue