Skip to content

Commit

Permalink
Merge pull request #312 from ZdruzenieSTROM/comment_permissions
Browse files Browse the repository at this point in the history
Fix number of comments and comment permissions
  • Loading branch information
mmihalik authored Dec 9, 2023
2 parents deb8926 + 6c2cb3f commit b5cae8a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions competition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b5cae8a

Please sign in to comment.