From 6c2cb3f86fc29b847b6779713f69526f0960dd1b Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sat, 9 Dec 2023 18:46:12 +0100 Subject: [PATCH] Fix number of comments and comment permissions --- competition/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/competition/models.py b/competition/models.py index 3865111d..a2a7907c 100644 --- a/competition/models.py +++ b/competition/models.py @@ -94,7 +94,7 @@ def get_seminar_by_site(cls, site): def get_seminar_by_current_site(cls): return cls.get_seminar_by_site(Site.objects.get_current()) - def can_user_modify(self, user): + def can_user_modify(self, user: User): return len(set(self.permission_group.all()).intersection(set(user.groups.all()))) > 0 @@ -408,9 +408,9 @@ def num_corrected_solutions(self): def can_user_modify(self, user): return self.series.can_user_modify(user) - def get_comments(self, user): - def filter_by_permissions(obj): - if user.is_staff: + def get_comments(self, user: User): + def filter_by_permissions(obj: 'Comment'): + if not user.is_anonymous and obj.can_user_modify(user): return True if obj.state == CommentPublishState.PUBLISHED: return True