Commit 1dc9140d authored by alexandre's avatar alexandre

Fix create function

parent 4fabf8d7
......@@ -43,6 +43,7 @@ class PermissionSerializer(serializers.Serializer):
list_serializer_class = PermissionListSerializer
class ScoreSerializer(TaggitSerializer, serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()
tags = TagListSerializerField()
......@@ -52,9 +53,10 @@ class ScoreSerializer(TaggitSerializer, serializers.HyperlinkedModelSerializer):
model = Score
fields = '__all__'
def create(self, request, *args, **kwargs):
instance = super().create(request, *args, **kwargs)
assign_perm("view_score", request.user, instance)
def create(self, validated_data):
validated_data.pop('permissions', None)
instance = Score.objects.create(**validated_data)
assign_perm("view_score", self.context['request'].user, instance)
return instance
def update(self, instance, validated_data):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment