Add set scoreboard view

This commit is contained in:
cuom1999 2020-12-27 19:59:57 -06:00
parent 8e1e3b246a
commit b3d80b5100
6 changed files with 34 additions and 1 deletions

View file

@ -68,6 +68,9 @@ class Contest(models.Model):
help_text=_('Whether the scoreboard should remain hidden for the duration '
'of the contest.'),
default=False)
view_contest_scoreboard = models.ManyToManyField(Profile, verbose_name=_('view contest scoreboard'), blank=True,
related_name='view_contest_scoreboard',
help_text=_('These users will be able to view the scoreboard.'))
use_clarifications = models.BooleanField(verbose_name=_('no comments'),
help_text=_("Use clarification system instead of comments."),
default=True)
@ -142,6 +145,8 @@ class Contest(models.Model):
return True
if user.is_authenticated and self.organizers.filter(id=user.profile.id).exists():
return True
if user.is_authenticated and self.view_contest_scoreboard.filter(id=user.profile.id).exists():
return True
if not self.is_visible:
return False
if self.start_time is not None and self.start_time > timezone.now():
@ -212,6 +217,8 @@ class Contest(models.Model):
# User is in the group of private contestants
if self.private_contestants.filter(id=user.profile.id).exists():
return True
if self.view_contest_scoreboard.filter(id=user.profile.id).exists():
return True
# If the user can view all contests
if user.has_perm('judge.see_private_contest'):