From 50f506cd93d95ac5c2a79597866ad5c3345b6aed Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Thu, 11 Feb 2021 13:58:41 -0600 Subject: [PATCH 1/6] Fix float precision in contest ranking --- judge/views/contests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/judge/views/contests.py b/judge/views/contests.py index 2ab511d..ba88d74 100644 --- a/judge/views/contests.py +++ b/judge/views/contests.py @@ -593,7 +593,8 @@ def base_contest_ranking_list(contest, problems, queryset): def contest_ranking_list(contest, problems): return base_contest_ranking_list(contest, problems, contest.users.filter(virtual=0, user__is_unlisted=False) .prefetch_related('user__organizations') - .order_by('is_disqualified', '-score', 'cumtime')) + .extra(select={'round_score': 'round(score, 6)'}) + .order_by('is_disqualified', '-round_score', 'cumtime')) def get_contest_ranking_list(request, contest, participation=None, ranking_list=contest_ranking_list, From f7fd4cae500f737cfac82efe6f55754c9b036ee6 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Thu, 18 Feb 2021 23:32:54 -0600 Subject: [PATCH 2/6] Add toggle button for ongoing contests --- templates/contest/list.html | 102 +++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/templates/contest/list.html b/templates/contest/list.html index 51117a6..791cb54 100644 --- a/templates/contest/list.html +++ b/templates/contest/list.html @@ -14,6 +14,18 @@ .content-description ul { padding: 0 !important; } + + .btn-contest { + display: inline-block; + padding: 1px 6px; + } + + {% if page_obj and page_obj.number > 1%} + #ongoing-table { + display: none; + } + {% endif %} + {% endblock %} @@ -32,6 +44,21 @@ '{{ _('Joining a contest for the first time starts your timer, after which it becomes unstoppable.') }}'); }); + function makeToggleBtn(btn, divElement) { + btn.click(function() { + divElement.toggle(300); + + if (btn.html().trim() === '{{ _('Hide')}}') { + btn.html('{{ _('Show')}}'); + } + else { + btn.html('{{ _('Hide')}}'); + } + }); + } + + makeToggleBtn($("#ongoing-btn"), $("#ongoing-table")); + // var tooltip_classes = 'tooltipped tooltipped-e'; // // $('.contest-tag').each(function () { @@ -187,41 +214,52 @@ {% endif %} {% if current_contests %} -

{{ _('Ongoing Contests') }}

- - - - - - {% if not request.in_contest %} - +

+ {{ _('Ongoing Contests') }} +

- - - {% for contest in current_contests %} + + +
+
{{ _('Contest') }}{{ _('Users') }}
+ - - - {{ contest_join(contest, request) }} + + + {% if not request.in_contest %} + + {% endif %} - {% endfor %} - -
-
- {{ contest_head(contest) }} - {% if contest.start_time %} -
- {% if contest.time_before_end %} - {{ _('Ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) }} - {% endif %} - {{ time_left(contest) }} - {% endif %} -
-
- {{ user_count(contest, request.user) }} - {{ _('Contest') }}{{ _('Users') }}
-
+ + + {% for contest in current_contests %} + + +
+ {{ contest_head(contest) }} + {% if contest.start_time %} +
+ {% if contest.time_before_end %} + {{ _('Ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) }} + {% endif %} + {{ time_left(contest) }} + {% endif %} +
+ + + {{ user_count(contest, request.user) }} + + {{ contest_join(contest, request) }} + + {% endfor %} + + +
+ {% endif %}

{{ _('Upcoming Contests') }}

From 628a3680d40ea87c7a177777cc173b5283ee5ded Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Fri, 19 Feb 2021 02:02:12 -0600 Subject: [PATCH 3/6] Add contest search --- judge/views/contests.py | 29 +++++++++++++++++-- templates/contest/list.html | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/judge/views/contests.py b/judge/views/contests.py index ba88d74..e95f1f4 100644 --- a/judge/views/contests.py +++ b/judge/views/contests.py @@ -31,7 +31,7 @@ from judge import event_poster as event from judge.comments import CommentedDetailView from judge.forms import ContestCloneForm from judge.models import Contest, ContestMoss, ContestParticipation, ContestProblem, ContestTag, \ - Problem, Profile, Submission + Organization, Problem, Profile, Submission from judge.tasks import run_moss from judge.utils.celery import redirect_to_task_status from judge.utils.opengraph import generate_opengraph @@ -86,9 +86,31 @@ class ContestList(DiggPaginatorMixin, TitleMixin, ContestListMixin, ListView): def _now(self): return timezone.now() + def get(self, request, *args, **kwargs): + self.contest_query = None + self.org_query = [] + + if 'orgs' in self.request.GET: + try: + self.org_query = list(map(int, request.GET.getlist('orgs'))) + except ValueError: + pass + + return super(ContestList, self).get(request, *args, **kwargs) + def _get_queryset(self): - return super(ContestList, self).get_queryset() \ + queryset = super(ContestList, self).get_queryset() \ .order_by('-start_time', 'key').prefetch_related('tags', 'organizations', 'organizers') + + if 'contest' in self.request.GET: + self.contest_query = query = ' '.join(self.request.GET.getlist('contest')).strip() + if query: + queryset = queryset.filter( + Q(key__icontains=query) | Q(name__icontains=query)) + if self.org_query: + queryset = queryset.filter(organizations__in=self.org_query) + + return queryset def get_queryset(self): return self._get_queryset().filter(end_time__lt=self._now) @@ -117,6 +139,9 @@ class ContestList(DiggPaginatorMixin, TitleMixin, ContestListMixin, ListView): context['future_contests'] = future context['now'] = self._now context['first_page_href'] = '.' + context['contest_query'] = self.contest_query + context['org_query'] = self.org_query + context['organizations'] = Organization.objects.all() return context diff --git a/templates/contest/list.html b/templates/contest/list.html index 791cb54..f10b067 100644 --- a/templates/contest/list.html +++ b/templates/contest/list.html @@ -26,6 +26,46 @@ } {% endif %} + @media (max-width: 500px) { + #search-contest, #search-org, #search-btn { + width: 100%; + margin-bottom: 0.5em; + } + #search-contest { + height: 2.5em; + } + #search-btn { + margin-top: 0.5em; + } + #filter-form input { + padding-left: 8px; + } + } + + @media (min-width: 500px) { + #filter-form input { + margin: 0 0.5em 0 0!important; + padding-left: 8px; + padding-top: 8px; + } + #search-contest { + width: 30%; + height: 2.3em; + margin-right: 1em; + margin-bottom: 0; + padding-top: 4px !important; + } + + #search-org { + width: 40%; + } + + #search-btn { + display: inline-block; + height: 2.3em; + margin-left: 0.5em; + } + } {% endblock %} @@ -59,6 +99,9 @@ makeToggleBtn($("#ongoing-btn"), $("#ongoing-table")); + $('#search-org').select2({multiple: 1, placeholder: '{{ _('Organizations...') }}'}) + .css({'visibility': 'visible'}); + // var tooltip_classes = 'tooltipped tooltipped-e'; // // $('.contest-tag').each(function () { @@ -171,6 +214,20 @@ {% block body %}
+ +
+ + + + +
{% if active_participations %}

{{ _('Active Contests') }}

From 7ae01bde13b7783c49781fcac1bb378aac81ed7a Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Fri, 19 Feb 2021 03:52:44 -0600 Subject: [PATCH 4/6] Change 502.html --- 502.html | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/502.html b/502.html index 4eb512a..98f4dbb 100644 --- a/502.html +++ b/502.html @@ -1,7 +1,7 @@ - 502 bad gateway - DMOJ + 502 bad gateway - LQDOJ {% if not request.in_contest %}