Skip to content

Commit

Permalink
fix create image over api
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Glatthard committed Aug 31, 2015
1 parent 981ca02 commit 47453b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ipynbsrv/api/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion ipynbsrv/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 47453b7

Please sign in to comment.