From dcc1cd5519b4f64473e420416b15cfc255d5552a Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sat, 13 Apr 2024 22:51:21 +0200 Subject: [PATCH] Opravena chyba pri kontrole permissions na probleme (#371) --- competition/serializers.py | 2 +- competition/views.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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(