diff --git a/ipynbsrv/api/serializer.py b/ipynbsrv/api/serializer.py index cc7337f..dc58473 100644 --- a/ipynbsrv/api/serializer.py +++ b/ipynbsrv/api/serializer.py @@ -206,6 +206,17 @@ class Meta: model = ContainerImage +class FlatContainerImageSerializer(serializers.ModelSerializer): + """ + Todo: write doc. + """ + friendly_name = serializers.CharField(read_only=True, source='get_friendly_name') + access_groups = FlatCollaborationGroupSerializer(many=True, read_only=True) + + class Meta: + model = ContainerImage + + class ContainerSnapshotSerializer(serializers.ModelSerializer): """ Todo: write doc. diff --git a/ipynbsrv/api/views.py b/ipynbsrv/api/views.py index 545433c..44cf685 100644 --- a/ipynbsrv/api/views.py +++ b/ipynbsrv/api/views.py @@ -712,7 +712,11 @@ class ContainerImageList(generics.ListCreateAPIView): """ Get a list of all the container images. """ - serializer_class = ContainerImageSerializer + + def get_serializer_class(self, *args, **kwargs): + if self.request.method in ['PATCH', 'POST', 'PUT']: + return FlatContainerImageSerializer + return ContainerImageSerializer def get_queryset(self): if self.request.user.is_superuser: