Skip to content

Commit

Permalink
Add contest tab and banner text
Browse files Browse the repository at this point in the history
  • Loading branch information
Riolku committed May 23, 2022
1 parent 84d4ba4 commit ae3a400
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
15 changes: 12 additions & 3 deletions templates/contest/contest-tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
{{ make_tab('stats', 'fa-pie-chart', url('contest_stats', contest.key), _('Statistics')) }}
{% endif %}

{% if is_editor or (is_tester and contest.can_see_own_testing_scoreboard(request.user)) %}
{{ make_tab('testing', 'fa-flask', url('contest_testing', contest.key), _('Testing')) }}
{% endif %}

{% if contest.start_time <= now or perms.judge.see_private_contest %}
{% if contest.can_see_own_scoreboard(request.user) %}
{{ make_tab('ranking', 'fa-bar-chart', url('contest_ranking', contest.key), _('Rankings')) }}
Expand All @@ -28,10 +32,9 @@

{% if request.user.is_authenticated %}
{% if contest.started or is_editor or is_tester %}
{% set in_contest = contest.is_in_contest(request.user) %}
{% if contest.ended %}
{# Allow users to leave the virtual contest #}
{% if in_contest %}
{% if is_in_contest %}
<form action="{{ url('contest_leave', contest.key) }}" method="post"
class="contest-join-pseudotab unselectable button">
{% csrf_token %}
Expand All @@ -47,7 +50,7 @@
{% endif %}
{% else %}
{# Allow users to leave the contest #}
{% if in_contest %}
{% if is_in_contest %}
<form action="{{ url('contest_leave', contest.key) }}" method="post"
class="contest-join-pseudotab unselectable button">
{% csrf_token %}
Expand All @@ -66,6 +69,12 @@
class="contest-join{% if not has_joined %} first-join{% endif %}"
value="{{ _('Join contest') }}">
</form>
{% elif can_test %}
<form action="{{ url('contest_join', contest.key) }}" method="post"
class="contest-join-pseudotab unselectable button">
{% csrf_token %}
<input type="submit" value="{{ _('Test contest') }}" class="contest-join">
</form>
{% elif can_spectate %}
<form action="{{ url('contest_join', contest.key) }}" method="post"
class="contest-join-pseudotab unselectable button">
Expand Down
24 changes: 20 additions & 4 deletions templates/contest/contest.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,30 @@
<div id="banner">
<a href="https://www.timeanddate.com/worldclock/fixedtime.html?msg={{ contest.name|urlquote('') }}&amp;iso=
{{- contest.start_time|utc|date('Y-m-d\TH:i:s') }}" class="date">
{%- if contest.is_in_contest(request.user) and not request.participation.live -%}
{%- if is_in_contest and not request.participation.live and not request.participation.testing -%}
{% if request.participation.spectate %}
{{- _('Spectating, contest ends in %(countdown)s.', countdown=contest.time_before_end|as_countdown) -}}
{% elif request.participation.end_time %}
{{- _('Participating virtually, %(countdown)s remaining.', countdown=request.participation.time_remaining|as_countdown) -}}
{% else %}
{{- _('Participating virtually.') -}}
{% endif %}
{%- elif has_started_testing -%}
{%- if testing_participation.ended -%}
{%- if not contest.started -%}
{{- _('Thanks for testing! Contest starts in %(countdown)s.', countdown=contest.time_before_start|as_countdown) -}}
{%- elif contest.ended -%}
{{- _('Thanks for testing! Contest is over.') -}}
{%- else -%}
{{- _('Thanks for testing! Contest ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) -}}
{%- endif -%}
{%- else -%}
{{- _('You have %(countdown)s remaining in testing.', countdown=testing_participation.time_remaining|as_countdown) -}}
{%- endif %}
{%- else -%}
{% if contest.start_time > now %}
{% if contest.started %}
{{- _('Starting in %(countdown)s', countdown=contest.time_before_start|as_countdown) -}}
{% elif contest.end_time < now %}
{% elif contest.ended %}
{{- _('Contest is over.') -}}
{% else %}
{%- if has_joined -%}
Expand Down Expand Up @@ -185,7 +197,11 @@
{% endcache %}
</div>

{% if contest.ended or request.user.is_superuser or is_editor or is_tester or (is_spectator and contest.started) %}
{% if
contest.ended or request.user.is_superuser or is_editor or
(is_tester and (contest.started or contest.has_completed_testing(request.user))) or
(is_spectator and contest.started)
%}
<hr>
<div class="contest-problems">
<h2 style="margin-bottom: 0.2em"><i class="fa fa-fw fa-question-circle"></i>{{ _('Problems') }} </h2>
Expand Down

0 comments on commit ae3a400

Please sign in to comment.