From 2e23d05a5930b52ad8e10ce3243338b1df39e262 Mon Sep 17 00:00:00 2001 From: masnn Date: Fri, 3 Apr 2020 20:56:20 +0800 Subject: [PATCH] template: problem_list --- templates/ac_mail.html | 4 +- templates/bsod.html | 49 ++--- templates/components/form.html | 128 ++++++------- templates/components/problem.html | 8 +- templates/components/sidemenu.html | 2 +- templates/contest_detail.html | 6 +- templates/discussion_detail.html | 2 +- templates/discussion_main_or_node.html | 2 +- templates/domain_main.html | 2 +- templates/error.html | 4 +- templates/homework_detail.html | 6 +- templates/partials/contest_sidebar.html | 6 +- templates/partials/footer.html | 6 +- templates/partials/homework_sidebar.html | 4 +- templates/partials/nav.html | 20 +-- templates/partials/problem_list.html | 29 +-- .../partials/problem_sidebar_contest.html | 10 +- .../partials/problem_sidebar_homework.html | 10 +- .../partials/problem_sidebar_normal.html | 32 ++-- templates/partials/problem_stat.html | 6 +- templates/problem_detail.html | 10 +- templates/problem_main.html | 168 ++++++++++-------- templates/problem_settings.html | 4 +- templates/record_detail.html | 2 +- templates/test.html | 87 +++++++++ templates/training_detail.html | 14 +- templates/training_main.html | 4 +- templates/user_detail.html | 2 +- 28 files changed, 357 insertions(+), 270 deletions(-) create mode 100644 templates/test.html diff --git a/templates/ac_mail.html b/templates/ac_mail.html index 1509afda9..147884087 100644 --- a/templates/ac_mail.html +++ b/templates/ac_mail.html @@ -1,8 +1,8 @@ {% extends "layout/mail.html" %} -{% block title %}{{ _('P{0} - {1} Accepted!').format(pdoc['doc_id'], pdoc['title']) }}{% endblock %} +{% block title %}{{ _('P{0} - {1} Accepted!').format(pdoc['_id'], pdoc['title']) }}{% endblock %} {% block content %}

{{ _('Congratulations! Your submission is accepted.') }}

-

{{ _('Problem') }}: P{{ pdoc['doc_id'] }} {{ pdoc['title'] }}

+

{{ _('Problem') }}: P{{ pdoc['_id'] }} {{ pdoc['title'] }}

{{ _('Code') }}:

 {{ rdoc['code'] }}
diff --git a/templates/bsod.html b/templates/bsod.html
index 8bee4016f..e1a41a9e5 100644
--- a/templates/bsod.html
+++ b/templates/bsod.html
@@ -1,28 +1,33 @@
 
 
-
-  Vijos System Error
-  
-  
-
-
-
#include <string.h>
-
+    
+        Vijos System Error
+        
+        
+    
+    
+        
+
+#include <string.h>
 int main() {
   char answer[42];
-  strcpy(answer, "twd2 will tell you the answer to life the universe and everything,");
-  strcpy(answer, "but first of all, he is very sorry that Vijos meets some issues now.");
-  strcpy(answer, "please wait patiently, or contact twd2 impatiently about this error.");
+  strcpy(answer, "masnn will tell you the answer to life the universe and everything,");
+  strcpy(answer, "but first of all, she is very sorry that Hydro meets some issues now.");
+  strcpy(answer, "please wait patiently, or contact masnn impatiently about this error.");
   return 0;
 }
-
- - +/* +{{error.stack}} +*/ +
+
+ + \ No newline at end of file diff --git a/templates/components/form.html b/templates/components/form.html index 11e38b64b..deefd9739 100644 --- a/templates/components/form.html +++ b/templates/components/form.html @@ -1,12 +1,12 @@ -{% macro form_begin() %} -{% set label = kwargs.pop('label') %} -{% set columns = kwargs.pop('columns') %} -{% set last_column = kwargs.pop('last_column', true) %} -{% set required = kwargs.pop('required', false) %} -{% set hotkeys = kwargs.pop('hotkeys', none) %} -{% set row = kwargs.pop('row', true) %} -{% set no_label = kwargs.pop('no_label', false) %} -{% set label_wrap = kwargs.pop('label_wrap', true) %} +{% macro form_begin(args) %} +{% set label = args.pop('label') %} +{% set columns = args.pop('columns') %} +{% set last_column = args.pop('last_column', true) %} +{% set required = args.pop('required', false) %} +{% set hotkeys = args.pop('hotkeys', none) %} +{% set row = args.pop('row', true) %} +{% set no_label = args.pop('no_label', false) %} +{% set label_wrap = args.pop('label_wrap', true) %} {% if row %}
{% endif %} @@ -26,11 +26,11 @@ {% endif %} {% endmacro %} -{% macro form_end() %} -{% set help_text = kwargs.pop('help_text', none) %} -{% set row = kwargs.pop('row', true) %} -{% set no_label = kwargs.pop('no_label', false) %} -{% set label_wrap = kwargs.pop('label_wrap', true) %} +{% macro form_end(args) %} +{% set help_text = args.pop('help_text', none) %} +{% set row = args.pop('row', true) %} +{% set no_label = args.pop('no_label', false) %} +{% set label_wrap = args.pop('label_wrap', true) %} {% if not no_label and label_wrap %} {% endif %} @@ -43,12 +43,12 @@ {% endif %} {% endmacro %} -{% macro form_attr(form_class) %} -{% set disabled = kwargs.pop('disabled', false) %} -{% set required = kwargs.pop('required', false) %} -{% set autofocus = kwargs.pop('autofocus', false) %} -{% set date = kwargs.pop('date', false) %} -{% set time = kwargs.pop('time', false) %} +{% macro form_attr(form_class, args) %} +{% set disabled = args.pop('disabled', false) %} +{% set required = args.pop('required', false) %} +{% set autofocus = args.pop('autofocus', false) %} +{% set date = args.pop('date', false) %} +{% set time = args.pop('time', false) %} class="{{ form_class }}{% if extra_class %} {{ extra_class }}{% endif %}" {% if disabled %}disabled{% endif %} {% if required %}required{% endif %} @@ -57,19 +57,19 @@ {% if time %}data-pick-time{% endif %} {% endmacro %} -{% macro container_attr(container_class) %} -{% set extra_class = kwargs.pop('extra_class', none) %} +{% macro container_attr(container_class, args) %} +{% set extra_class = args.pop('extra_class', none) %} class="{{ container_class }}{% if extra_class %} {{ extra_class }}{% endif %}" {% endmacro %} -{% macro select(options, name='', value='') %} +{% macro select(options, name='', value='', args) %}
{% endmacro %} -{% macro form_text(columns=5) %} -{{ form_begin(columns=columns, **kwargs) }} -{{ text(columns=columns, **kwargs) }} -{{ form_end(columns=columns, **kwargs) }} +{% macro form_text(columns=5, args) %} +{{ form_begin({columns:columns}|assign(args)) }} +{{ text({columns:columns}|assign(args)) }} +{{ form_end({columns:columns}|assign(args)) }} {% endmacro %} -{% macro textarea(name='', value='', placeholder='') %} -{% set markdown = kwargs.pop('markdown', false) %} +{% macro textarea(name='', value='', placeholder='', args) %} +{% set markdown = args.pop('markdown', false) %}
{% endmacro %} {% macro form_textarea(columns=8) %} -{{ form_begin(columns=columns, **kwargs) }} -{{ textarea(columns=columns, **kwargs) }} -{{ form_end(columns=columns, **kwargs) }} +{{ form_begin({columns:columns}|assign(args)) }} +{{ textarea({columns:columns}|assign(args)) }} +{{ form_end({columns:columns}|assign(args)) }} {% endmacro %} -{% macro checkbox(label='', name='', value=false) %} +{% macro checkbox(label='', name='', value=false, args) %}
{% endmacro %} -{% macro form_checkbox(columns=5) %} -{{ form_begin(columns=columns, no_label=True, **kwargs) }} -{{ checkbox(columns=columns, **kwargs) }} -{{ form_end(columns=columns, no_label=True, **kwargs) }} +{% macro form_checkbox(columns=5, args) %} +{{ form_begin({columns:columns, no_label:true}|assign(args)) }} +{{ checkbox({columns:columns}|assign(args)) }} +{{ form_end({columns:columns, no_label:true}|assign(args)) }} {% endmacro %} diff --git a/templates/components/problem.html b/templates/components/problem.html index c8bbbd526..94a83fd57 100644 --- a/templates/components/problem.html +++ b/templates/components/problem.html @@ -2,15 +2,15 @@ {%- if not invalid %} {%- endif %} - {% if pdoc['doc_id']|string|length < 10 %}P{{ pdoc['doc_id'] }} {% endif %}{{ pdoc['title'] }} + {% if pdoc['_id']|string|length < 10 %}P{{ pdoc['_id'] }} {% endif %}{{ pdoc['title'] }} {%- if not invalid %} {%- endif %} diff --git a/templates/components/sidemenu.html b/templates/components/sidemenu.html index 92bb8e498..293bf2467 100644 --- a/templates/components/sidemenu.html +++ b/templates/components/sidemenu.html @@ -1,6 +1,6 @@ {% macro render_item(icon_name, page_name, label=none) %} {% else %} - {% endif %} - {% elif handler.is_done(tdoc) %} - {% endif %} {% if handler.own(pdoc, vj4.model.builtin.PERM_EDIT_PROBLEM_SELF) or handler.has_perm(vj4.model.builtin.PERM_EDIT_PROBLEM) %} - - {% endif %} diff --git a/templates/partials/problem_sidebar_homework.html b/templates/partials/problem_sidebar_homework.html index cf3d03172..b4e24f784 100644 --- a/templates/partials/problem_sidebar_homework.html +++ b/templates/partials/problem_sidebar_homework.html @@ -16,24 +16,24 @@ {{ _('Quit Scratchpad') }} (Alt+Q) {% else %} - {% endif %} - {% elif handler.is_done(tdoc) %} - {% endif %} {% if handler.own(pdoc, vj4.model.builtin.PERM_EDIT_PROBLEM_SELF) or handler.has_perm(vj4.model.builtin.PERM_EDIT_PROBLEM) %} - - {% endif %} diff --git a/templates/partials/problem_sidebar_normal.html b/templates/partials/problem_sidebar_normal.html index 9497adab7..9be87cbae 100644 --- a/templates/partials/problem_sidebar_normal.html +++ b/templates/partials/problem_sidebar_normal.html @@ -10,11 +10,11 @@
- {% if pdoc['doc_id']|string|length < 10 %} + {% if pdoc['_id']|string|length < 10 %}
{{ _('ID') }}
-
{{ pdoc['doc_id'] }}
+
{{ pdoc['_id'] }}
{% endif %} {% if page_name != 'discussion_node' and page_name != 'discussion_detail' %} - {% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %} + {% if handler.has_perm(perm.PERM_LOGGEDIN) %}
{{ _('Submission') }}
{% if pdoc['psdoc']['status'] %} @@ -141,11 +141,11 @@ {{ problem.render_problem_tags(pdoc, true) }}
{{ _('# Submissions') }}
-
{{ pdoc['num_submit'] }}
+
{{ pdoc['num_submit'] }}
{% if page_name != 'discussion_node' and page_name != 'discussion_detail' %} - {% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %} + {% if handler.has_perm(perm.PERM_LOGGEDIN) %}
{{ _('# My Submissions') }}
-
{{ pdoc['psdoc']['num_submit']|default(0) }}
+
{{ pdoc['psdoc']['num_submit']|default(0) }}
{% endif %} {% endif %}
{{ _('Accepted') }}
diff --git a/templates/partials/problem_stat.html b/templates/partials/problem_stat.html index 8ce43767d..6ea2ba065 100644 --- a/templates/partials/problem_stat.html +++ b/templates/partials/problem_stat.html @@ -1,3 +1,3 @@ -
-

{{ _('{0} problems').format(pcount) }}

-
+
+

{{ _('{0} problems').format(pcount) }}

+
\ No newline at end of file diff --git a/templates/problem_detail.html b/templates/problem_detail.html index 7782816c4..42969403c 100644 --- a/templates/problem_detail.html +++ b/templates/problem_detail.html @@ -29,11 +29,11 @@
-
-
-
-
- {% include "partials/problem_list.html" %} -
-
-
-
-
-
-

{{ _('Categories') }}

-
-
    - {% for category, sub_categories in categories.items() %} -
  • -

    {{ category }}

    - {% if sub_categories|length > 0 %} -
      - {% for sub_category in sub_categories %} -
    1. {{ sub_category }}
    2. - {% endfor %} -
    - {% endif %} -
  • - {% endfor %} -
-
- {% include "partials/problem_lucky.html" %} -
-
-
-
-

{{ _('Search') }}

-
-
-
- - - + +
+
+
+
+ {% include "partials/problem_list.html" %} +
+
- -
- {% if handler.has_perm(vj4.model.builtin.PERM_CREATE_PROBLEM) %} -
-
-

{{ _('Create Problem') }}

-
- -
-
-

{{ _('You have permissions to create problems for this domain.') }}

+
+
+
+

{{ _('Categories') }}

+
+
+
    + {% for category in builtin.CATEGORIES %} + {% for sub_categories in category %} +
  • +

    + {{ category }} +

    + {% if sub_categories | length > 0 %} +
      + {% for sub_category in sub_categories %} +
    1. + {{ sub_category }} +
    2. + {% endfor %} +
    + {% endif %} +
  • + {% endfor %} + {% endfor %} +
+
+
+ {% include "partials/problem_lucky.html" %} +
+
+
+
+

{{ _('Search') }}

+
+
+
+ + + +
+
+
+ {% if handler.has_perm(vj4.model.builtin.PERM_CREATE_PROBLEM) %} +
+
+

{{ _('Create Problem') }}

+
+ +
+
+

{{ _('You have permissions to create problems for this domain.') }}

+
+
+
+ {% endif %} +
+
+

{{ _('Statistics') }}

+
+ {% include "partials/problem_stat.html" %} +
-
- {% endif %} -
-
-

{{ _('Statistics') }}

-
- {% include "partials/problem_stat.html" %} -
-
-
-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/templates/problem_settings.html b/templates/problem_settings.html index 26f75f251..959c0d218 100644 --- a/templates/problem_settings.html +++ b/templates/problem_settings.html @@ -7,10 +7,10 @@

{{ _('Dataset') }}

- +

{{ _('Hint') }}: {{ _('Dataset Format') }}, {{ _('An example of dataset') }}: {{ _('Download') }}

{% if pdoc and (handler.own(pdoc, vj4.model.builtin.PERM_READ_PROBLEM_DATA_SELF) or handler.has_perm(vj4.model.builtin.PERM_READ_PROBLEM_DATA) or handler.has_priv(vj4.model.builtin.PRIV_READ_PROBLEM_DATA)) %} -

{{ _('Download Dataset') }}

+

{{ _('Download Dataset') }}

{% endif %}
diff --git a/templates/record_detail.html b/templates/record_detail.html index de5709a52..59acaffb6 100644 --- a/templates/record_detail.html +++ b/templates/record_detail.html @@ -81,7 +81,7 @@
{{ _('Download') }}
{% elif rdoc['type'] == vj4.constant.record.TYPE_SUBMISSION and pdoc and (handler.own(pdoc, vj4.model.builtin.PERM_READ_PROBLEM_DATA_SELF) or handler.has_perm(vj4.model.builtin.PERM_READ_PROBLEM_DATA) or handler.has_priv(vj4.model.builtin.PRIV_READ_PROBLEM_DATA)) %}
{{ _('Problem Data') }}
-
{{ _('Download') }}
+
{{ _('Download') }}
{% endif %}
{{ _('Language') }}
diff --git a/templates/test.html b/templates/test.html new file mode 100644 index 000000000..55fbccc70 --- /dev/null +++ b/templates/test.html @@ -0,0 +1,87 @@ +{% macro form_begin(kwargs) %} +{% set label = kwargs.pop('label') %} +{% set columns = kwargs.pop('columns') %} +{% set last_column = kwargs.pop('last_column', true) %} +{% set required = kwargs.pop('required', false) %} +{% set hotkeys = kwargs.pop('hotkeys', none) %} +{% set row = kwargs.pop('row', true) %} +{% set no_label = kwargs.pop('no_label', false) %} +{% set label_wrap = kwargs.pop('label_wrap', true) %} +{% if row %} +
+{% endif %} +
+ {% if not no_label %} + + {% endif %} + {% endif %} +{% endmacro %} + +{% macro form_end(kwargs) %} +{% set help_text = kwargs.pop('help_text', none) %} +{% set row = kwargs.pop('row', true) %} +{% set no_label = kwargs.pop('no_label', false) %} +{% set label_wrap = kwargs.pop('label_wrap', true) %} + {% if not no_label and label_wrap %} + + {% endif %} + {% if help_text %} +

{{ _(help_text)|safe }}

+ {% endif %} +
+{% if row %} +
+{% endif %} +{% endmacro %} + +{% macro form_attr(form_class, kwargs) %} +{% set disabled = kwargs.pop('disabled', false) %} +{% set required = kwargs.pop('required', false) %} +{% set autofocus = kwargs.pop('autofocus', false) %} +{% set date = kwargs.pop('date', false) %} +{% set time = kwargs.pop('time', false) %} + class="{{ form_class }}{% if extra_class %} {{ extra_class }}{% endif %}" + {% if disabled %}disabled{% endif %} + {% if required %}required{% endif %} + {% if autofocus %}autofocus data-autofocus{% endif %} + {% if date %}data-pick-date{% endif %} + {% if time %}data-pick-time{% endif %} +{% endmacro %} + +{% macro container_attr(container_class, kwargs) %} +{% set extra_class = kwargs.pop('extra_class', none) %} + class="{{ container_class }}{% if extra_class %} {{ extra_class }}{% endif %}" +{% endmacro %} + +{% macro select(options, name='', value='', kwargs) %} +
+ +
+{% endmacro %} + +{% macro form_select(columns=5) %} +{{ form_begin({columns:1, ...kwargs}, kwargs) }} +{{ select(columns=columns, kwargs) }} +{{ form_end(columns=columns, kwargs) }} +{% endmacro %} diff --git a/templates/training_detail.html b/templates/training_detail.html index cff56ed7e..348bf451b 100644 --- a/templates/training_detail.html +++ b/templates/training_detail.html @@ -79,7 +79,7 @@
- {% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %} + {% if handler.has_perm(perm.PERM_LOGGEDIN) %} {% endif %} @@ -89,7 +89,7 @@ - {% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %} + {% if handler.has_perm(perm.PERM_LOGGEDIN) %} {% endif %} @@ -103,7 +103,7 @@ {% if pid in pdict %} {% with pdoc=pdict[pid], psdoc=psdict[pid] %} - {% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %} + {% if handler.has_perm(perm.PERM_LOGGEDIN) %} {% if psdoc['rid'] %} {{ record.render_status_td(psdoc, rid_key='rid') }} {% else %} @@ -111,9 +111,9 @@ {% endif %} {% endif %}
{{ _('Status') }}{{ _('Problem') }}
- {% if handler.has_priv(vj4.model.builtin.PRIV_USER_PROFILE) %} + {% if handler.has_perm(perm.PERM_LOGGEDIN) %}
- +