From 756023a097d413cb0260ce441d7a409949ebc6a0 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sun, 27 Nov 2022 01:03:38 -0600 Subject: [PATCH] Rewrite contest UI --- judge/views/contests.py | 8 +-- judge/widgets/select2.py | 4 +- resources/blog.scss | 13 ++-- resources/contest.scss | 1 - templates/contest/calendar.html | 20 ++++-- templates/contest/contest-datetime.html | 53 ++++++++++++++++ templates/contest/contest-list-tabs.html | 31 ++------- templates/contest/contest-tabs.html | 55 ++++++++-------- templates/contest/contest.html | 80 +++--------------------- templates/contest/list.html | 6 +- templates/contest/moss.html | 18 +++--- templates/contest/ranking-css.html | 4 -- templates/contest/ranking.html | 17 ++--- templates/contest/stats.html | 15 ++--- templates/organization/users.html | 2 +- templates/three-column-content.html | 11 ++++ templates/user/base-users-three-col.html | 35 ----------- templates/user/base-users-two-col.html | 35 +++++++++++ templates/user/base-users.html | 35 ----------- templates/user/list.html | 2 +- 20 files changed, 191 insertions(+), 254 deletions(-) create mode 100644 templates/contest/contest-datetime.html delete mode 100644 templates/user/base-users-three-col.html create mode 100644 templates/user/base-users-two-col.html delete mode 100644 templates/user/base-users.html diff --git a/judge/views/contests.py b/judge/views/contests.py index 5873fd4..743ea30 100644 --- a/judge/views/contests.py +++ b/judge/views/contests.py @@ -988,7 +988,7 @@ def contest_ranking_ajax(request, contest, participation=None): class ContestRankingBase(ContestMixin, TitleMixin, DetailView): template_name = "contest/ranking.html" - tab = None + page_type = None def get_title(self): raise NotImplementedError() @@ -1008,12 +1008,12 @@ class ContestRankingBase(ContestMixin, TitleMixin, DetailView): users, problems = self.get_ranking_list() context["users"] = users context["problems"] = problems - context["tab"] = self.tab + context["page_type"] = self.page_type return context class ContestRanking(ContestRankingBase): - tab = "ranking" + page_type = "ranking" def get_title(self): return _("%s Rankings") % self.object.name @@ -1039,7 +1039,7 @@ class ContestRanking(ContestRankingBase): class ContestParticipationList(LoginRequiredMixin, ContestRankingBase): - tab = "participation" + page_type = "participation" def get_title(self): if self.profile == self.request.profile: diff --git a/judge/widgets/select2.py b/judge/widgets/select2.py index 3439689..8329e42 100644 --- a/judge/widgets/select2.py +++ b/judge/widgets/select2.py @@ -48,9 +48,7 @@ from django.urls import reverse_lazy from django.utils.http import urlencode DEFAULT_SELECT2_JS = settings.STATIC_URL + "libs/select2/select2.js" -DEFAULT_SELECT2_CSS = settings.STATIC_URL + ( - "libs/select2/select2.css" -) +DEFAULT_SELECT2_CSS = settings.STATIC_URL + ("libs/select2/select2.css") __all__ = [ "Select2Widget", diff --git a/resources/blog.scss b/resources/blog.scss index 465f058..e327686 100644 --- a/resources/blog.scss +++ b/resources/blog.scss @@ -173,14 +173,13 @@ } .left-sidebar-item { + display: flex; + align-items: center; .sidebar-icon { font-size: large; - width: 1.2em; display: inline-block; - i { - position: relative; - bottom: -1.5px; + width: 1.4em; } } } @@ -271,12 +270,12 @@ } .middle-content { - max-width: 65%; - margin-left: 13%; + max-width: 75%; + width: -webkit-fill-available; } .blog-sidebar, .right-sidebar { - width: 20%; + width: 25%; } .left-sidebar { diff --git a/resources/contest.scss b/resources/contest.scss index 246f48c..efc6e50 100644 --- a/resources/contest.scss +++ b/resources/contest.scss @@ -91,7 +91,6 @@ } #banner { - border-bottom: 1px solid rgba(0, 0, 0, 0.2); padding-bottom: 1em; a.date { diff --git a/templates/contest/calendar.html b/templates/contest/calendar.html index f79b3e2..e35a4ea 100644 --- a/templates/contest/calendar.html +++ b/templates/contest/calendar.html @@ -1,12 +1,22 @@ -{% extends "base.html" %} -{% block title_ruler %}{% endblock %} +{% extends "two-column-content.html" %} +{% set page_type = 'calendar' %} -{% block title_row %} - {% set tab = 'calendar' %} +{% block left_sidebar %} {% include "contest/contest-list-tabs.html" %} {% endblock %} -{% block body %} +{% block middle_content %} +
+ {% if prev_month %} + « {{ _('Prev') }} + {% endif %} + {% if not (curr_month.year == now.year and curr_month.month == now.month) %} + {{ _('Today') }} + {% endif %} + {% if next_month %} + {{ _('Next') }} » + {% endif %} +
diff --git a/templates/contest/contest-datetime.html b/templates/contest/contest-datetime.html new file mode 100644 index 0000000..470661b --- /dev/null +++ b/templates/contest/contest-datetime.html @@ -0,0 +1,53 @@ + + \ No newline at end of file diff --git a/templates/contest/contest-list-tabs.html b/templates/contest/contest-list-tabs.html index 1687831..66e565a 100644 --- a/templates/contest/contest-list-tabs.html +++ b/templates/contest/contest-list-tabs.html @@ -1,26 +1,5 @@ -{% extends "tabs-base.html" %} - -{% block post_tab_spacer %} - {% if tab == 'calendar' %} -
- {% if prev_month %} - « {{ _('Prev') }} - {% endif %} - {% if not (curr_month.year == now.year and curr_month.month == now.month) %} - {{ _('Today') }} - {% endif %} - {% if next_month %} - {{ _('Next') }} » - {% endif %} -
- - {% endif %} -{% endblock %} - -{% block tabs %} - {{ make_tab('list', 'fa-list', url('contest_list'), _('List')) }} - {{ make_tab('calendar', 'fa-calendar', url('contest_calendar', now.year, now.month), _('Calendar')) }} - {% if perms.judge.change_contest %} - {{ make_tab('admin', 'fa-edit', url('admin:judge_contest_changelist'), _('Admin')) }} - {% endif %} -{% endblock %} + \ No newline at end of file diff --git a/templates/contest/contest-tabs.html b/templates/contest/contest-tabs.html index 996f846..950c2d8 100644 --- a/templates/contest/contest-tabs.html +++ b/templates/contest/contest-tabs.html @@ -1,31 +1,4 @@ -{% extends "tabs-base.html" %} - -{% block tabs %} - {{ make_tab('detail', 'fa-info-circle', url('contest_view', contest.key), _('Info')) }} - {% if contest.ended or can_edit %} - {{ make_tab('stats', 'fa-pie-chart', url('contest_stats', contest.key), _('Statistics')) }} - {% 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')) }} - {% if request.user.is_authenticated %} - {{ make_tab('participation', 'fa-users', url('contest_participation_own', contest.key), _('Participation')) }} - {% endif %} - {% else %} - {{ make_tab('ranking', 'fa-bar-chart', None, _('Hidden Rankings')) }} - {% endif %} - {% endif %} - {% if can_edit %} - {% if perms.judge.moss_contest and has_moss_api_key %} - {{ make_tab('moss', 'fa-gavel', url('contest_moss', contest.key), _('MOSS')) }} - {% endif %} - {{ make_tab('edit', 'fa-edit', url('admin:judge_contest_change', contest.id), _('Edit')) }} - {% endif %} - {% if perms.judge.clone_contest %} - {{ make_tab('clone', 'fa-copy', url('contest_clone', contest.key), _('Clone')) }} - {% endif %} - + diff --git a/templates/contest/contest.html b/templates/contest/contest.html index 91a49fa..d6f744b 100644 --- a/templates/contest/contest.html +++ b/templates/contest/contest.html @@ -1,78 +1,24 @@ -{% extends "common-content.html" %} - -{% block title_ruler %}{% endblock %} - -{% block title_row %} - {% set tab = 'detail' %} +{% extends "two-column-content.html" %} +{% set page_type = 'detail' %} + +{% block left_sidebar %} {% set title = contest.name %} {% include "contest/contest-tabs.html" %} {% endblock %} -{% block content_js_media %} - +{% block two_col_js %} {% include "contest/media-js.html" %} {% include "comments/media-js.html" %} {% include "actionbar/media-js.html" %} {% endblock %} -{% block content_media %} +{% block two_col_media %} {% include "comments/media-css.html" %} {% include "actionbar/media-css.html" %} {% endblock %} -{% block body %} - +{% block middle_content %} + {% include "contest/contest-datetime.html" %}
{% cache 3600 'contest_html' contest.id MATH_ENGINE %} @@ -128,12 +74,4 @@ {% include "actionbar/list.html" %}
{% include "comments/list.html" %} -{% endblock %} - -{% block description_end %}{% endblock %} - -{% block bodyend %} - {{ super() }} - {% include "comments/math.html" %} -{% endblock %} -k +{% endblock %} \ No newline at end of file diff --git a/templates/contest/list.html b/templates/contest/list.html index 22e6bd5..4077391 100644 --- a/templates/contest/list.html +++ b/templates/contest/list.html @@ -106,11 +106,7 @@ {% endblock %} {% block left_sidebar %} - + {% include "contest/contest-list-tabs.html" %} {% endblock %} {% macro contest_head(contest) %} diff --git a/templates/contest/moss.html b/templates/contest/moss.html index 143bcd3..8ca86e2 100644 --- a/templates/contest/moss.html +++ b/templates/contest/moss.html @@ -1,14 +1,11 @@ -{% extends "common-content.html" %} - -{% block title_ruler %}{% endblock %} - -{% block title_row %} - {% set tab = 'moss' %} - {% set title = contest.name %} +{% extends "two-column-content.html" %} +{% set page_type = 'moss' %} + +{% block left_sidebar %} {% include "contest/contest-tabs.html" %} {% endblock %} -{% block content_media %} +{% block two_col_media %} {% endblock %} -{% block content_js_media %} +{% block two_col_js %} {% endblock %} -{% block body %} + +{% block middle_content %} {% if has_results %}
{{ _('Sunday') }}
diff --git a/templates/contest/ranking-css.html b/templates/contest/ranking-css.html index 4f5b96d..26273a0 100644 --- a/templates/contest/ranking-css.html +++ b/templates/contest/ranking-css.html @@ -1,8 +1,4 @@ {% endblock %} -{% block body %} +{% block middle_content %}

{{ _('Problem Status Distribution') }}

diff --git a/templates/organization/users.html b/templates/organization/users.html index 8cd5863..241227c 100644 --- a/templates/organization/users.html +++ b/templates/organization/users.html @@ -1,4 +1,4 @@ -{% extends "user/base-users-three-col.html" %} +{% extends "user/base-users-two-col.html" %} {% block users_media %}