Skip to content

Commit

Permalink
allow users to see own participation after window
Browse files Browse the repository at this point in the history
To provide a better UX, especially for fully-hidden contests, 
contestants can now see their own participation after they have 
completed the contest.
  • Loading branch information
Riolku authored and quantum5 committed Feb 22, 2022
1 parent cf34cf6 commit 7c05b2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion judge/models/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def can_see_own_scoreboard(self, user):
return True
if not self.can_join:
return False
if not self.show_scoreboard and not self.is_in_contest(user):
if not self.show_scoreboard and not self.is_in_contest(user) and not self.has_completed_contest(user):
return False
return True

Expand Down
9 changes: 8 additions & 1 deletion judge/models/tests/test_contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def test_contest_hidden_scoreboard_contest_methods(self):
'has_completed_contest': self.assertFalse,
},
'normal_after_window': {
'can_see_own_scoreboard': self.assertFalse,
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertFalse,
'has_completed_contest': self.assertTrue,
},
Expand Down Expand Up @@ -461,24 +461,31 @@ def test_visible_scoreboard_contest_methods(self):
def test_full_hidden_scoreboard_contest_methods(self):
data = {
'superuser': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertTrue,
},
'non_staff_tester': {
'can_see_own_scoreboard': self.assertFalse,
'can_see_full_scoreboard': self.assertFalse,
},
'non_staff_author': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertTrue,
},
'staff_contest_edit_own': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertTrue,
},
'staff_contest_edit_all': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertTrue,
},
'normal': {
'can_see_own_scoreboard': self.assertFalse,
'can_see_full_scoreboard': self.assertFalse,
},
'normal_after_window': {
'can_see_own_scoreboard': self.assertTrue,
'can_see_full_scoreboard': self.assertFalse,
},
}
Expand Down

0 comments on commit 7c05b2f

Please sign in to comment.