NDOJ/templates/contest/list.html

372 lines
12 KiB
HTML
Raw Normal View History

2024-05-06 03:47:57 +00:00
{% extends "three-column-content.html" %}
2020-01-21 06:35:58 +00:00
{% block meta %}
2023-01-27 23:11:10 +00:00
<meta name="description" content="The {{ SITE_NAME }}'s contest list - past, present, and future.">
2020-01-21 06:35:58 +00:00
{% endblock %}
2024-05-06 03:47:57 +00:00
{% block three_col_media %}
2023-01-27 23:11:10 +00:00
<style>
2023-09-08 16:22:57 +00:00
.non-padding-top {
padding-top: 0;
}
2023-01-27 23:11:10 +00:00
.btn-contest {
display: inline-block;
padding: 1px 6px;
}
2021-02-19 05:32:54 +00:00
2023-01-27 23:11:10 +00:00
.contest-group-header {
2024-05-06 03:47:57 +00:00
margin-bottom: 1em;
2023-01-27 23:11:10 +00:00
}
2022-11-09 20:45:46 +00:00
2023-01-27 23:11:10 +00:00
{% if page_obj and page_obj.number > 1%}
#ongoing-table {
display: none;
}
{% endif %}
2021-02-19 05:32:54 +00:00
2024-05-06 03:47:57 +00:00
#search-contest {
width: 100%;
height: 2.3em;
2023-01-27 23:11:10 +00:00
}
2024-05-06 03:47:57 +00:00
#search-org {
width: 100%;
2023-01-27 23:11:10 +00:00
}
</style>
2020-01-21 06:35:58 +00:00
{% endblock %}
2024-05-06 03:47:57 +00:00
{% block three_col_js %}
2023-01-27 23:11:10 +00:00
<script src="{{ static('libs/featherlight/featherlight.min.js') }}" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
2023-02-08 19:12:23 +00:00
var $form = $('form#filter-form');
2024-05-06 03:47:57 +00:00
$('#show_orgs').click(function () {
($('<form>').attr('action', window.location.pathname + '?' + $form.serialize())
.append($('<input>').attr('type', 'hidden').attr('name', 'csrfmiddlewaretoken')
.attr('value', $.cookie('csrftoken')))
.attr('method', 'POST').appendTo($('body')).submit());
});
$('#go').click(function() {
2023-02-08 19:12:23 +00:00
$form.submit();
});
2023-01-27 23:11:10 +00:00
$('.time-remaining').each(function () {
count_down($(this));
});
2020-01-21 06:35:58 +00:00
2023-01-27 23:11:10 +00:00
$('.contest-tag').find('a[data-featherlight]').featherlight();
2020-01-21 06:35:58 +00:00
2023-01-27 23:11:10 +00:00
$('.join-warning').click(function () {
let q = '{{ _('Are you sure you want to join?') }}\n' +
'{{ _('Joining a contest for the first time starts your timer, after which it becomes unstoppable.') }}';
{% if request.in_contest %}
q += " {{ _('By joining in this contest, you will automatically leave contest') }} \"{{ request.participation.contest.name }}\". ";
{% endif %}
return confirm(q);
2023-01-27 23:11:10 +00:00
});
2020-01-21 06:35:58 +00:00
2024-05-06 03:47:57 +00:00
$('#search-contest').keypress(function (e) {
if (e.keyCode == 13)
$('#go').click();
});
$('#search-org').select2({multiple: 1, placeholder: '{{ _('Groups') }}...'});
2021-02-19 08:02:12 +00:00
2023-01-27 23:11:10 +00:00
// var tooltip_classes = 'tooltipped tooltipped-e';
//
// $('.contest-tag').each(function () {
// var link = $(this);//
// link.mouseenter(function (e) {
// link.addClass(tooltip_classes).attr('aria-label', link.attr('data-description'));
// }).mouseleave(function (e) {
// link.removeClass(tooltip_classes).removeAttr('aria-label');
// });
// });
});
</script>
2020-01-21 06:35:58 +00:00
{% endblock %}
2022-05-28 04:28:22 +00:00
{% block left_sidebar %}
2023-01-27 23:11:10 +00:00
{% include "contest/contest-list-tabs.html" %}
2020-01-21 06:35:58 +00:00
{% endblock %}
2024-05-06 03:47:57 +00:00
{% block right_sidebar %}
<div class="right-sidebar">
{% include "contest/search-form.html" %}
</div>
{% endblock %}
2020-01-21 06:35:58 +00:00
{% macro contest_head(contest) %}
2023-10-05 06:09:09 +00:00
<a href="{{ url('contest_view', contest.key) }}" class="contest-list-title" style="margin-right: 5px;">
{{contest.name}}
</a>
2024-04-23 20:36:51 +00:00
<div class="contest-tags">
2023-10-05 06:09:09 +00:00
{% if not contest.is_visible %}
<span class="contest-tag contest-tag-hidden">
<i class="fa fa-eye-slash"></i> {{ _('hidden') }}
</span>
{% endif %}
{% if contest.is_editable %}
<span class="contest-tag contest-tag-edit">
<a href="{{ url('organization_contest_edit', organization.id, organization.slug, contest.key) }}" class="white">
<i class="fa fa-edit"></i> {{ _('Edit') }}
</a>
</span>
{% endif %}
{% if contest.is_private %}
<span class="contest-tag contest-tag-private">
<i class="fa fa-lock"></i> {{ _('private') }}
</span>
{% endif %}
{% if not hide_contest_orgs %}
{% if contest.is_organization_private %}
{% for org in contest.organizations.all() %}
2024-04-23 20:36:51 +00:00
{% include "organization/tag.html" %}
2023-10-05 06:09:09 +00:00
{% endfor %}
2023-01-27 23:11:10 +00:00
{% endif %}
2023-10-05 06:09:09 +00:00
{% endif %}
{% if contest.is_rated %}
<span class="contest-tag contest-tag-rated">
<i class="fa fa-bar-chart"></i> {{ _('rated') }}
</span>
{% endif %}
{% for tag in contest.tags.all() %}
<span style="background-color: {{ tag.color }}" class="contest-tag">
<a href="{{ url('contest_tag', tag.name) }}"
style="color: {{ tag.text_color }}"
data-featherlight="{{ url('contest_tag_ajax', tag.name) }}">
{{- tag.name -}}
</a>
</span>
{% endfor %}
</div>
2020-01-21 06:35:58 +00:00
{% endmacro %}
2024-04-23 20:36:51 +00:00
{% macro time_left(contest) %}
<div class="time-left">
2023-01-27 23:11:10 +00:00
{% if contest.time_limit %}
2024-04-23 20:36:51 +00:00
<div>
2024-05-06 03:47:57 +00:00
<b>{{_("Start")}}</b>: {{ contest.start_time|date(_("H:i d/m/Y")) }}
2024-04-23 20:36:51 +00:00
</div>
<div>
2024-05-06 03:47:57 +00:00
<b>{{_("End")}}</b>: {{ contest.end_time|date(_("H:i d/m/Y")) }}
2024-04-23 20:36:51 +00:00
</div>
2023-01-27 23:11:10 +00:00
{% else %}
2024-04-23 20:36:51 +00:00
<div>
2024-05-06 03:47:57 +00:00
<b>{{_("Start")}}</b>: {{ contest.start_time|date(_("H:i d/m/Y")) }}
2024-04-23 20:36:51 +00:00
</div>
2023-01-27 23:11:10 +00:00
{% endif %}
2024-05-06 03:47:57 +00:00
<div>
<b>{{_("Length")}}</b>:
{% if contest.time_limit %}
{% trans time_limit=contest.time_limit|timedelta('localized-no-seconds') %}{{ time_limit }}{% endtrans %}
{% else %}
{% trans duration=contest.contest_window_length|timedelta('localized-no-seconds') %}{{ duration }}{% endtrans %}
{% endif %}
</div>
2023-01-27 23:11:10 +00:00
</div>
2020-01-21 06:35:58 +00:00
{% endmacro %}
{% macro user_count(contest, user) %}
2023-01-27 23:11:10 +00:00
{% if contest.can_see_own_scoreboard(user) %}
2024-05-06 03:47:57 +00:00
<a href="{{ url('contest_ranking', contest.key) }}"><i class="fa fa-users"></i> {{ contest.user_count }}</a>
2023-01-27 23:11:10 +00:00
{% else %}
2024-05-06 03:47:57 +00:00
<i class="fa fa-users"></i>{{ contest.user_count }}
2023-01-27 23:11:10 +00:00
{% endif %}
2020-01-21 06:35:58 +00:00
{% endmacro %}
{% macro contest_join(contest, request) %}
{% if request.in_contest and request.participation.contest == contest %}
<button class="small" disabled>{{ _('In contest') }}</button>
2024-04-25 06:58:47 +00:00
{% elif request.profile.id in contest.editor_ids or request.profile.id in contest.tester_ids %}
<form action="{{ url('contest_join', contest.key) }}" method="post">
{% csrf_token %}
<input type="submit" class="unselectable button full small"
value="{{ _('Spectate') }}">
</form>
{% else %}
<form action="{{ url('contest_join', contest.key) }}" method="post">
{% csrf_token %}
<input type="submit" class="unselectable button full small join-warning"
value="{{ _('Join') }}">
</form>
2023-01-27 23:11:10 +00:00
{% endif %}
2020-01-21 06:35:58 +00:00
{% endmacro %}
2024-05-06 03:47:57 +00:00
{% macro contest_format_user(contest, show_user=True) %}
<div style="display: flex; flex-direction: column; height: 100%;">
<div class="contest-title"> {{ _('Format') }} </div>
<div style="flex-grow: 1">{{ contest.format.name }}</div>
{% if show_user %}
<div class="contest-title">{{ user_count(contest, request.user) }}</div>
2024-04-23 20:36:51 +00:00
{% endif %}
2024-05-06 03:47:57 +00:00
</div>
{% endmacro %}
2024-04-23 20:36:51 +00:00
2024-05-06 03:47:57 +00:00
{% block middle_content %}
2024-04-23 20:36:51 +00:00
<div id="ongoing-table">
2023-01-27 23:11:10 +00:00
{% if active_participations %}
<h3 class="toggle open contest-group-header">
<i class="fa fa-chevron-right fa-fw"></i>
{{ _('Active Contests') }}
</h3>
<div class="toggled">
2023-09-08 16:22:57 +00:00
{% for participation in active_participations %}
{% with contest=participation.contest %}
<div class="list-contest">
2024-04-23 20:36:51 +00:00
<div class="info-contest">
2023-09-08 16:22:57 +00:00
<div class="contest-title"> {{ _('Contests') }} </div>
{{ contest_head(contest) }}
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest">
2023-09-08 16:22:57 +00:00
<div class="contest-title"> {{ _('Time') }} </div>
<div class="contest-block">
{% if contest.start_time %}
2024-04-23 20:36:51 +00:00
{{ time_left(contest) }}
2023-09-08 16:22:57 +00:00
{% if contest.time_limit %}
<span class="time">
{% trans countdown=participation.end_time|as_countdown %}Window ends in {{countdown}}{% endtrans %}
</span>
{% elif contest.time_before_end %}
<span class="time">{% trans countdown=contest.end_time|as_countdown %}Ends in {{countdown}}{% endtrans %}</span>
{% endif %}
{% endif %}
</div>
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest" style="flex: 0.5;">
2024-05-06 03:47:57 +00:00
{{ contest_format_user(contest) }}
2023-09-08 16:22:57 +00:00
</div>
<div class="participate-button">
{{ contest_join(contest, request) }}
</div>
</div>
{% endwith %}
{% endfor %}
2023-01-27 23:11:10 +00:00
</div>
{% endif %}
2020-01-21 06:35:58 +00:00
<h3 class="toggle open contest-group-header">
<i class="fa fa-chevron-right fa-fw"></i>
{{ _('Ongoing Contests') }}
</h3>
2023-01-27 23:11:10 +00:00
{% if current_contests %}
2024-04-23 20:36:51 +00:00
<div class="toggled">
2023-09-08 16:22:57 +00:00
{% for contest in current_contests %}
<div class="list-contest">
2024-04-23 20:36:51 +00:00
<div class="info-contest">
2023-09-08 16:22:57 +00:00
<div class="contest-title"> {{ _('Contests') }} </div>
{{ contest_head(contest) }}
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest">
2023-09-08 16:22:57 +00:00
<div class="contest-title"> {{ _('Time') }} </div>
<div class="contest-block">
{% if contest.start_time %}
2024-04-23 20:36:51 +00:00
{{ time_left(contest) }}
2023-09-08 16:22:57 +00:00
{% if contest.time_before_end %}
<span class="time">{% trans countdown=contest.end_time|as_countdown %}Ends in {{countdown}}{% endtrans %}</span>
{% endif %}
{% endif %}
</div>
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest" style="flex: 0.5;">
2024-05-06 03:47:57 +00:00
{{ contest_format_user(contest) }}
2023-09-08 16:22:57 +00:00
</div>
<div class="participate-button">
{{ contest_join(contest, request) }}
</div>
</div>
{% endfor %}
2023-01-27 23:11:10 +00:00
</div>
{% else %}
<div class="toggled">
<i> {{ _('There is no ongoing contest at this time.') }} </i>
2024-04-23 20:36:51 +00:00
<br><br>
</div>
2023-01-27 23:11:10 +00:00
{% endif %}
2020-01-21 06:35:58 +00:00
2023-01-27 23:11:10 +00:00
<h3 class="toggle open contest-group-header">
<i class="fa fa-chevron-right fa-fw"></i>
{{ _('Upcoming Contests') }}
</h3>
{% if future_contests %}
<div class="toggled">
2023-09-08 16:22:57 +00:00
{% for contest in future_contests %}
<div class="list-contest">
2024-04-23 20:36:51 +00:00
<div class="info-contest">
2023-09-08 16:22:57 +00:00
<div class="contest-title"> {{ _('Contests') }} </div>
{{ contest_head(contest) }}
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest">
2023-09-08 16:22:57 +00:00
<div class="contest-title"> {{ _('Time') }} </div>
<div class="contest-block">
{% if contest.start_time %}
2024-04-23 20:36:51 +00:00
{{ time_left(contest) }}
2023-09-08 16:22:57 +00:00
{% if contest.time_before_start %}
<span class="time">{{ _('Starting in %(countdown)s.', countdown=contest.start_time|as_countdown) }}</span>
{% endif %}
{% endif %}
</div>
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest" style="flex: 0.5;">
2024-05-06 03:47:57 +00:00
{{ contest_format_user(contest, show_user=False) }}
2023-09-08 16:22:57 +00:00
</div>
</div>
{% endfor %}
2023-01-27 23:11:10 +00:00
</div>
{% else %}
<div class="toggled">
<i>{{ _('There is no scheduled contest at this time.') }}</i>
2024-04-23 20:36:51 +00:00
<br><br>
</div>
2023-01-27 23:11:10 +00:00
{% endif %}
2024-04-23 20:36:51 +00:00
</div>
2023-01-27 23:11:10 +00:00
2024-04-23 20:36:51 +00:00
<h3 class="toggle open contest-group-header">
{{ _('Past Contests') }}
</h3>
{% if past_contests %}
{% if page_obj and page_obj.num_pages > 1 %}
<div style="margin-bottom: 10px;">
{% include "list-pages.html" %}
</div>
{% endif %}
2023-09-08 16:22:57 +00:00
2024-04-23 20:36:51 +00:00
{% for contest in past_contests %}
<div class="list-contest">
<div class="info-contest">
<div class="contest-title"> {{ _('Contests') }} </div>
{{ contest_head(contest) }}
</div>
<div class="info-contest">
<div class="contest-title"> {{ _('Time') }} </div>
<div class="contest-block">
{{ time_left(contest) }}
2023-09-08 16:22:57 +00:00
</div>
</div>
2024-04-23 20:36:51 +00:00
<div class="info-contest" style="flex: 0.5;">
2024-05-06 03:47:57 +00:00
{{ contest_format_user(contest) }}
2024-04-23 20:36:51 +00:00
</div>
<div class="participate-button">
{% if request.in_contest and request.participation.contest == contest %}
<button class="small" disabled>{{ _('In contest') }}</button>
{% else %}
2024-04-23 20:36:51 +00:00
<form action="{{ url('contest_join', contest.key) }}" method="post">
{% csrf_token %}
<input type="submit" class="unselectable button full small"
value="{{ _('Virtual join') }}">
</form>
{% endif %}
</div>
2024-04-23 20:36:51 +00:00
</div>
{% endfor %}
{% if page_obj and page_obj.num_pages > 1 %}
<div style="margin-top: 10px;">
{% include "list-pages.html" %}
</div>
2023-01-27 23:11:10 +00:00
{% endif %}
2024-04-23 20:36:51 +00:00
{% else %}
<div class="toggled">
<i> {{ _('There is no past contest.') }} </i>
<br>
</div>
{% endif %}
2020-01-21 06:35:58 +00:00
{% endblock %}