mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 14:54:22 +00:00
🐛 Fix the serializer used by notebook actions
This commit is contained in:
parent
986652a4b1
commit
f4e0fdccb8
2 changed files with 9 additions and 6 deletions
|
@ -381,7 +381,10 @@ class Notebook(SophonGroupModel):
|
|||
|
||||
if self.container_id is None:
|
||||
return None
|
||||
return docker_client.containers.get(self.container_id)
|
||||
try:
|
||||
return docker_client.containers.get(self.container_id)
|
||||
except docker.errors.NotFound:
|
||||
return None
|
||||
|
||||
def sync_container(self) -> t.Optional[docker.models.containers.Container]:
|
||||
"""
|
||||
|
|
|
@ -31,7 +31,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
|
|||
"""
|
||||
notebook: Notebook = self.get_object()
|
||||
notebook.sync_container()
|
||||
Serializer = notebook.get_access_serializer(request.user)
|
||||
Serializer = self.get_serializer_class()
|
||||
serializer = Serializer(notebook)
|
||||
return Response(serializer.data, status.HTTP_200_OK)
|
||||
|
||||
|
@ -42,7 +42,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
|
|||
"""
|
||||
notebook: Notebook = self.get_object()
|
||||
notebook.start()
|
||||
Serializer = notebook.get_access_serializer(request.user)
|
||||
Serializer = self.get_serializer_class()
|
||||
serializer = Serializer(notebook)
|
||||
return Response(serializer.data, status.HTTP_200_OK)
|
||||
|
||||
|
@ -57,7 +57,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
|
|||
if notebook.locked_by is None:
|
||||
notebook.locked_by = self.request.user
|
||||
notebook.save()
|
||||
Serializer = notebook.get_access_serializer(request.user)
|
||||
Serializer = self.get_serializer_class()
|
||||
serializer = Serializer(notebook)
|
||||
return Response(serializer.data, status.HTTP_200_OK)
|
||||
|
||||
|
@ -71,7 +71,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
|
|||
notebook: Notebook = self.get_object()
|
||||
notebook.locked_by = None
|
||||
notebook.save()
|
||||
Serializer = notebook.get_access_serializer(request.user)
|
||||
Serializer = self.get_serializer_class()
|
||||
serializer = Serializer(notebook)
|
||||
return Response(serializer.data, status.HTTP_200_OK)
|
||||
|
||||
|
@ -82,7 +82,7 @@ class NotebooksViewSet(SophonGroupViewSet, metaclass=abc.ABCMeta):
|
|||
"""
|
||||
notebook: Notebook = self.get_object()
|
||||
notebook.stop()
|
||||
Serializer = notebook.get_access_serializer(request.user)
|
||||
Serializer = self.get_serializer_class()
|
||||
serializer = Serializer(notebook)
|
||||
return Response(serializer.data, status.HTTP_200_OK)
|
||||
|
||||
|
|
Loading…
Reference in a new issue