Skip to content

Commit

Permalink
feature: add moss config in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tc-imba committed Oct 11, 2019
1 parent df97d3c commit a1988ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
5 changes: 3 additions & 2 deletions vj4/handler/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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
Expand Down
48 changes: 25 additions & 23 deletions vj4/ui/templates/homework_system_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,35 @@ <h1 class="section__title">{{ _('Export') }}</h1>
</form>
</div>
</div>
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Moss') }}</h1>
</div>
{% if 'moss_url' in tdoc %}
<div class="section__body typo">
Last result: <a target="_blank" href="{{ tdoc['moss_url'] }}">{{ tdoc['moss_url'] }}</a>
{% if moss_user_id != 987654321 %}
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Moss') }}</h1>
</div>
{% endif %}
<div class="section__body">
<form method="post" action="moss">
<div class="row">
{{ 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 %}
<div class="section__body typo">
Last result: <a target="_blank" href="{{ tdoc['moss_url'] }}">{{ tdoc['moss_url'] }}</a>
</div>
<div class="row">
<div class="columns">
<input type="hidden" name="csrf_token" value="{{ handler.csrf_token }}">
<button type="submit" class="rounded primary button">
{{ _('Moss') }}
</button>
{% endif %}
<div class="section__body">
<form method="post" action="moss">
<div class="row">
{{ 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) }}
</div>
</div>
</form>
<div class="row">
<div class="columns">
<input type="hidden" name="csrf_token" value="{{ handler.csrf_token }}">
<button type="submit" class="rounded primary button">
{{ _('Moss') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}

0 comments on commit a1988ab

Please sign in to comment.