Skip to content

Commit

Permalink
Opravena chyba pri kontrole permissions na probleme (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe authored Apr 13, 2024
1 parent b5d75ec commit dcc1cd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion competition/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit dcc1cd5

Please sign in to comment.