Make public scoreboard better

This commit is contained in:
cuom1999 2023-09-17 00:44:07 -05:00
parent 3f72466e3d
commit ad278f58a9
2 changed files with 11 additions and 4 deletions

View file

@ -278,6 +278,10 @@ class ContestMixin(object):
def can_edit(self):
return self.object.is_editable_by(self.request.user)
@cached_property
def can_access(self):
return self.object.is_accessible_by(self.request.user)
def should_bypass_access_check(self, contest):
return False
@ -304,6 +308,7 @@ class ContestMixin(object):
context["is_editor"] = self.is_editor
context["is_tester"] = self.is_tester
context["can_edit"] = self.can_edit
context["can_access"] = self.can_access
if not self.object.og_image or not self.object.summary:
metadata = generate_opengraph(

View file

@ -7,15 +7,17 @@
}
</style>
<div class="left-sidebar">
{{ make_tab_item('detail', 'fa fa-info-circle', url('contest_view', contest.key), _('Info')) }}
{% if contest.ended or can_edit %}
{{ make_tab_item('stats', 'fa fa-pie-chart', url('contest_stats', contest.key), _('Statistics')) }}
{% if can_access %}
{{ make_tab_item('detail', 'fa fa-info-circle', url('contest_view', contest.key), _('Info')) }}
{% if contest.ended or can_edit %}
{{ make_tab_item('stats', 'fa fa-pie-chart', url('contest_stats', contest.key), _('Statistics')) }}
{% endif %}
{% endif %}
{% if contest.start_time <= now or perms.judge.see_private_contest %}
{% if contest.can_see_own_scoreboard(request.user) %}
{{ make_tab_item('ranking', 'fa fa-bar-chart', url('contest_ranking', contest.key), _('Rankings')) }}
{% if request.user.is_authenticated %}
{% if request.user.is_authenticated and can_access %}
{{ make_tab_item('participation', 'fa fa-users', url('contest_participation_own', contest.key), _('Participation')) }}
{% endif %}
{% else %}