Skip to content

Commit

Permalink
Always show join/spectate buttons in contest list (#312)
Browse files Browse the repository at this point in the history
Co-authored-by: Le Duy Thuc <leduythuc.cs@gmail.com>
  • Loading branch information
hieplpvip and leduythuccs authored May 23, 2023
1 parent 9a1d3c3 commit 70cac22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions locale/vi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4631,7 +4631,7 @@ msgstr "Báo cáo mới"

#: templates/blog/list.html:111 templates/contest/list.html:192
msgid "Ongoing contests"
msgstr "Kỳ thi đang diễn ra"
msgstr "Các kỳ thi đang diễn ra"

#: templates/blog/list.html:119
#, python-format
Expand All @@ -4640,7 +4640,7 @@ msgstr "Kết thúc trong %(countdown)s."

#: templates/blog/list.html:129 templates/contest/list.html:229
msgid "Upcoming contests"
msgstr "Kỳ thi sắp tới"
msgstr "Các kỳ thi sắp tới"

#: templates/blog/list.html:137 templates/contest/contest.html:55
#, python-format
Expand Down
27 changes: 18 additions & 9 deletions templates/contest/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@
{% if not request.official_contest_mode %}
$('.join-warning').click(function () {
return confirm('{{ _('Are you sure you want to join?') }}\n' +
'{{ _('Joining a contest for the first time starts your timer, after which it becomes unstoppable.') }}');
'{{ _('Joining a contest for the first time starts your timer, after which it becomes unstoppable.') }}'
{% if request.in_contest %}
+ '\n{{ _('Joining this contest will leave %(contest)s.', contest=request.participation.contest.name) }}'
{% endif %}
);
});
{% endif %}

{% if request.in_contest %}
$('.spectate-warning').click(function () {
return confirm('{{ _('Are you sure you want to spectate?') }}\n' +
'{{ _('Spectating this contest will leave %(contest)s.', contest=request.participation.contest.name) }}');
});
{% endif %}

Expand Down Expand Up @@ -133,12 +144,14 @@
{% endmacro %}

{% macro contest_join(contest, request, finished_contests) %}
{% if not request.in_contest %}
{% if request.in_contest and contest.key == request.participation.contest.key %}
<td><span>Already joined</span></td>
{% else %}
<td>
{% if contest.key in finished_contests or request.profile in contest.authors.all() or request.profile in contest.curators.all() or request.profile in contest.testers.all() %}
<form action="{{ url('contest_join', contest.key) }}" method="post">
{% csrf_token %}
<input type="submit" class="unselectable button full participate-button"
<input type="submit" class="unselectable button full participate-button spectate-warning"
value="{{ _('Spectate') }}">
</form>
{% else %}
Expand Down Expand Up @@ -189,9 +202,7 @@ <h4>{{ _('Active contests') }}</h4>
<tr>
<th style="width:80%">{{ _('Contest') }}</th>
<th>{{ _('Users') }}</th>
{% if not request.in_contest %}
<th style="width:20%"></th>
{% endif %}
<th style="width:20%"></th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -231,9 +242,7 @@ <h4>{{ _('Ongoing contests') }}</h4>
<tr>
<th style="width:80%">{{ _('Contest') }}</th>
<th>{{ _('Users') }}</th>
{% if not request.in_contest %}
<th style="width:15%"></th>
{% endif %}
<th style="width:15%"></th>
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit 70cac22

Please sign in to comment.