Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix number of comments and comment permissions #312

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading