diff --git a/competition/serializers.py b/competition/serializers.py index 8e9d643..1c40ee1 100644 --- a/competition/serializers.py +++ b/competition/serializers.py @@ -157,7 +157,7 @@ class ProblemSerializer(serializers.ModelSerializer): class Meta: model = models.Problem fields = '__all__' - read_only_fields = ['series', 'submitted', 'num_comments'] + read_only_fields = ['submitted', 'num_comments'] submitted = serializers.SerializerMethodField( 'get_submitted') diff --git a/competition/views.py b/competition/views.py index ef878cd..dff464a 100644 --- a/competition/views.py +++ b/competition/views.py @@ -202,7 +202,8 @@ def perform_create(self, serializer): Volá sa pri vytvarani objektu, checkuju sa tu permissions, ci user vie vytvorit problem v danej sutazi """ - if Problem.can_user_create(self.request.user, serializer.validated_data): + series = serializer.validated_data['series'] + if series.can_user_modify(self.request.user): serializer.save() else: raise exceptions.PermissionDenied(