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

🔧 Use higher-level get_serializer_class in actions

This commit is contained in:
Steffo 2021-10-20 20:46:12 +02:00
parent 0e5c908062
commit 240f588f37
2 changed files with 7 additions and 7 deletions

View file

@ -223,7 +223,7 @@ class ResearchGroupViewSet(WriteSophonViewSet):
group.members.add(self.request.user) group.members.add(self.request.user)
# noinspection PyPep8Naming # noinspection PyPep8Naming
Serializer = group.get_access_serializer(self.request.user) Serializer = self.get_serializer_class()
serializer = Serializer(instance=group) serializer = Serializer(instance=group)
return Response(data=serializer.data, status=s.HTTP_200_OK) return Response(data=serializer.data, status=s.HTTP_200_OK)
@ -244,7 +244,7 @@ class ResearchGroupViewSet(WriteSophonViewSet):
group.members.remove(self.request.user) group.members.remove(self.request.user)
# noinspection PyPep8Naming # noinspection PyPep8Naming
Serializer = group.get_access_serializer(self.request.user) Serializer = self.get_serializer_class()
serializer = Serializer(instance=group) serializer = Serializer(instance=group)
return Response(data=serializer.data, status=s.HTTP_200_OK) return Response(data=serializer.data, status=s.HTTP_200_OK)

View file

@ -25,7 +25,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
""" """
notebook: Notebook = self.get_object() notebook: Notebook = self.get_object()
notebook.sync_container() notebook.sync_container()
Serializer = notebook.get_access_serializer(request.user) Serializer = self.get_serializer_class()
serializer = Serializer(notebook) serializer = Serializer(notebook)
return Response(serializer.data, status.HTTP_200_OK) return Response(serializer.data, status.HTTP_200_OK)
@ -36,7 +36,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
""" """
notebook: Notebook = self.get_object() notebook: Notebook = self.get_object()
notebook.start() notebook.start()
Serializer = notebook.get_access_serializer(request.user) Serializer = self.get_serializer_class()
serializer = Serializer(notebook) serializer = Serializer(notebook)
return Response(serializer.data, status.HTTP_200_OK) return Response(serializer.data, status.HTTP_200_OK)
@ -51,7 +51,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
if notebook.locked_by is None: if notebook.locked_by is None:
notebook.locked_by = self.request.user notebook.locked_by = self.request.user
notebook.save() notebook.save()
Serializer = notebook.get_access_serializer(request.user) Serializer = self.get_serializer_class()
serializer = Serializer(notebook) serializer = Serializer(notebook)
return Response(serializer.data, status.HTTP_200_OK) return Response(serializer.data, status.HTTP_200_OK)
@ -65,7 +65,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
notebook: Notebook = self.get_object() notebook: Notebook = self.get_object()
notebook.locked_by = None notebook.locked_by = None
notebook.save() notebook.save()
Serializer = notebook.get_access_serializer(request.user) Serializer = self.get_serializer_class()
serializer = Serializer(notebook) serializer = Serializer(notebook)
return Response(serializer.data, status.HTTP_200_OK) return Response(serializer.data, status.HTTP_200_OK)
@ -76,7 +76,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
""" """
notebook: Notebook = self.get_object() notebook: Notebook = self.get_object()
notebook.stop() notebook.stop()
Serializer = notebook.get_access_serializer(request.user) Serializer = self.get_serializer_class()
serializer = Serializer(notebook) serializer = Serializer(notebook)
return Response(serializer.data, status.HTTP_200_OK) return Response(serializer.data, status.HTTP_200_OK)