From a1988abe5346dd343be3c2f049d80cf65c7b2163 Mon Sep 17 00:00:00 2001 From: tc-imba Date: Fri, 11 Oct 2019 18:39:57 +0800 Subject: [PATCH] feature: add moss config in Dockerfile --- Dockerfile | 6 ++- vj4/handler/contest.py | 5 ++- vj4/ui/templates/homework_system_test.html | 48 +++++++++++----------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index fed7478d..4f3779ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,8 @@ ENV HOST="localhost" \ DB_HOST="localhost" \ DB_NAME="cb4-production" \ MQ_HOST="localhost" \ - MQ_VHOST="/" + MQ_VHOST="/" \ + MOSS_USER_ID=987654321 EXPOSE $PORT @@ -62,4 +63,5 @@ CMD python3 -m vj4.server \ --db-host=$DB_HOST \ --db-name=$DB_NAME \ --mq-host=$MQ_HOST \ - --mq_vhost=$MQ_VHOST + --mq_vhost=$MQ_VHOST \ + --moss-user-id=$MOSS_USER_ID diff --git a/vj4/handler/contest.py b/vj4/handler/contest.py index 9350398c..5b5e631f 100644 --- a/vj4/handler/contest.py +++ b/vj4/handler/contest.py @@ -24,7 +24,7 @@ from vj4.model.adaptor import moss from vj4.model.adaptor import problem from vj4.handler import base -from vj4.util import pagination +from vj4.util import pagination, options from vj4.util.misc import filter_language, filter_content_type _logger = logging.getLogger(__name__) @@ -840,7 +840,8 @@ async def _get_homework(self, *, tid: objectid.ObjectId): (self.translate('page.contest_main.homework.title'), self.reverse_url('contest_main', ctype='homework')), (tdoc['title'], self.reverse_url('contest_detail', ctype='homework', tid=tdoc['doc_id'])), (page_title, None)) - self.render('homework_system_test.html', tdoc=tdoc, + print(tdoc) + self.render('homework_system_test.html', tdoc=tdoc, moss_user_id=options.moss_user_id, page_title=page_title, path_components=path_components) @base.route_argument diff --git a/vj4/ui/templates/homework_system_test.html b/vj4/ui/templates/homework_system_test.html index d68d3ba3..a4469201 100644 --- a/vj4/ui/templates/homework_system_test.html +++ b/vj4/ui/templates/homework_system_test.html @@ -38,33 +38,35 @@

{{ _('Export') }}

-
-
-

{{ _('Moss') }}

-
- {% if 'moss_url' in tdoc %} -
- Last result: {{ tdoc['moss_url'] }} + {% if moss_user_id != 987654321 %} +
+
+

{{ _('Moss') }}

- {% endif %} -
-
-
- {{ form.form_select2(columns=3, label='Code language', name='language', options=vj4.constant.language.LANG_MOSS.items(), row=false) }} - {{ form.form_text(columns=6, label='Filter Wildcards', help_text='Splitted by \', \'. Use default settings of the selected language if empty.', name='wildcards', value='', row=false) }} - {{ form.form_text(columns=3, label='Ignore Threshold', help_text='Ignore if a range of code appears in a number of submissions. Minimum is 2. Default is 10.', name='ignore_limit', value=10, row=false) }} + {% if 'moss_url' in tdoc %} +
+ Last result: {{ tdoc['moss_url'] }}
-
-
- - + {% endif %} +
+ +
+ {{ form.form_select2(columns=3, label='Code language', name='language', options=vj4.constant.language.LANG_MOSS.items(), row=false) }} + {{ form.form_text(columns=6, label='Filter Wildcards', help_text='Splitted by \', \'. Use default settings of the selected language if empty.', name='wildcards', value='', row=false) }} + {{ form.form_text(columns=3, label='Ignore Threshold', help_text='Ignore if a range of code appears in a number of submissions. Minimum is 2. Default is 10.', name='ignore_limit', value=10, row=false) }}
-
- +
+
+ + +
+
+ +
-
+ {% endif %}
{% endblock %}