core&ui: add contest private files (#1053)

Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
undefinedandpanda authored and GitHub committed 2025-10-17 10:24:38 +01:00
1 parent 9729346ad9
commit f5ef8b7f38
35 files changed
+781 -843

No files matched your search

@@ -0,0 +1,103 @@
{% extends "layout/basic.html" %}
{% import "components/contest.html" as contest with context %}
{% import "components/problem.html" as problem with context %}
{% block content %}
{{ set(UiContext, 'tdoc', tdoc) }}
<div class="row">
<div class="medium-9 columns">
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Contest Clarifications') }}</h1>
<div class="section__tools">
<a href="#reply_or_broadcast" class="primary rounded button" name="broadcast" data-title="{{ _('Send Broadcast Message') }}" data-did="">{{ _('Send Broadcast Message') }}</a>
</div>
</div>
<div class="section__body">
{% if not tcdocs.length %}
{{ nothing.render('Oh, there is no clarification!', compact=true) }}
{% else %}
<ul class="dczcomments__list">
{% for doc in tcdocs %}
<li class="dczcomments__item" id="clarification_{{ doc._id }}" data-did="{{ doc._id }}">
<div class="media">
<div class="media__body top" style="max-width:100%">
<div class="clearfix">
<div class="supplementary dczcomments__supplementary">
{{_('Subject') }}: {{ contest.render_clarification_subject(tdoc,pdict,doc.subject) }} | {% if doc.owner == 0 %}<b>{{ _('Jury') }}</b>{% else %}{{ user.render_inline(udict[doc.owner], badge=false) }}{% endif %} @ {{ datetimeSpan(doc._id)|safe }}
</div>
{% if doc.owner %}
<div class="dczcomments__operations nojs--hide">
<a href="#reply_or_broadcast" name="reply" data-title="{{ _('Reply') }}#{{ doc._id }}" data-did="{{ doc._id }}"
><span class="icon icon-reply"></span>{{ _('Reply') }}</a>
</div>
{% endif %}
</div>
<div class="typo richmedia" data-emoji-enabled>
{{ doc['content']|markdown|safe }}
</div>
</div>
</div>
<ul class="dczcomments__replies">
{%- for rdoc in doc['reply'] -%}
<li class="dczcomments__reply">
<div class="media">
<div class="media__left top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="media__body top">
<div class="clearfix">
<div class="supplementary dczcomments__supplementary">
<b>{{ _('Jury') }}</b>
</div>
</div>
<div class="typo richmedia" data-emoji-enabled>
{{ rdoc['content']|markdown|safe }}
</div>
</div>
</div>
</li>
{%- endfor -%}
</ul>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
<div id="reply_or_broadcast">
<div class="section__header">
<h1 class="section__title">{{ _('Send Broadcast Message') }}</h1>
</div>
<div class="section__body typo">
<form method="post">
<div class="clarification-container"></div>
<input type="hidden" name="operation" value="clarification">
<input type="hidden" name="did" value="">
<div class="row">
<div class="medium-12 columns form__item_subject">
<label>
{{ _('Subject') }}
<select name="subject" class="select">
<option value="0">{{ _('General Issue') }}</option>
<option value="-1">{{ _('Technical Issue') }}</option>
{% for pid in tdoc.pids %}
<option value="{{ pid }}">{{ utils.getAlphabeticId(loop.index0) }}. {{ pdict[pid].title }}</option>
{% endfor %}
</select>
</label>
</div>
<div class="medium-12 columns form__item">
<label>
{{ _('Content') }}
<textarea name="content" class="textbox" data-markdown required></textarea>
</label>
</div>
</div>
<button type="submit" class="rounded primary button">{{ _('Submit') }}</button>
</form>
</div>
</div>
</div>
</div>
<div class="medium-3 columns">
{% include 'partials/contest_sidebar_management.html' %}
</div>
</div>
{% endblock %}
@@ -38,11 +38,12 @@
{% endif %}
</div>
</div>
{% if tdoc.files.length %}
{% if files.length %}
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Files') }}</h1>
</div>
{% set filetype = 'private' %}
{% include "partials/files.html" %}
</div>
{% endif %}
@@ -228,6 +228,20 @@
</div>
</div>
<div class="medium-3 columns">
{% if tdoc %}
<div class="section side">
<div class="section__header">
<h1 class="section__title">{{ _('Files') }}</h1>
<div class="section__tools">
<button class="primary rounded button" name="upload_file">{{ _('Upload') }}</button>
</div>
</div>
{% set sidebar = true %}
{% set files = tdoc.files %}
{% set filetype = "public" %}
{% include "partials/files.html" %}
</div>
{% endif %}
{% include 'components/md_hint.html' %}
</div>
</div>
+45 -118
View File
@@ -5,142 +5,69 @@
{{ set(UiContext, 'tdoc', tdoc) }}
<div class="row">
<div class="medium-9 columns">
<div class="row">
<div class="medium-7 columns">
<div class="section">
<div class="section__body no-padding">
<table class="data-table">
<colgroup>
<col class="col--problem">
<col class="col--score">
</colgroup>
<thead>
<tr>
<th class="col--problem">{{ _('Problem') }}</th>
<th class="col--score">{{ _('Score') }}</th>
</tr>
</thead>
<tbody>
{%- for pid in tdoc.pids -%}
<tr>
<td class="col--problem col--problem-name">
<a href="{{ url('problem_detail', pid=pid) }}">
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, invalid=true, alphabetic=true) }}
</a>
</td>
<td class="col--score">
<a class="typo-a" data-tooltip="{{ _('Set Score for Contest') }}" name="set_score" data-pid="{{ pid }}" data-score="{{ tdoc.score[pid]|default(100) }}">{{ tdoc.score[pid]|default(100) }}</a>
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
</div>
<div class="section">
<div class="section__body no-padding">
<table class="data-table">
<colgroup>
<col class="col--id">
<col class="col--problem">
<col class="col--score">
</colgroup>
<thead>
<tr>
<th class="col--id">{{ _('ID') }}</th>
<th class="col--problem">{{ _('Problem') }}</th>
<th class="col--score">{{ _('Score') }}</th>
</tr>
</thead>
<tbody>
{%- for pid in tdoc.pids -%}
<tr>
<td class="col--id">{{ pdict[pid].docId }}</td>
<td class="col--problem col--problem-name">
<a href="{{ url('problem_detail', pid=pid) }}">
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, invalid=true, alphabetic=true) }}
</a>
</td>
<td class="col--score">
<a class="typo-a" data-tooltip="{{ _('Set Score for Contest') }}" name="set_score" data-pid="{{ pid }}" data-score="{{ tdoc.score[pid]|default(100) }}">{{ tdoc.score[pid]|default(100) }}</a>
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
<div class="medium-5 columns">
<div class="section">
</div>
<div class="row">
<div class="medium-6 columns">
<div class="section" data-type="public">
<div class="section__header">
<h1 class="section__title">{{ _('Files') }}</h1>
<h1 class="section__title">{{ _('Files') }}({{ _('Public') }})</h1>
<div class="section__tools">
<button class="primary rounded button" name="upload_file">{{ _('Upload File') }}</button>
</div>
</div>
{{ noscript_note.render() }}
{% set filetype = "public" %}
{% include "partials/files.html" %}
<div class="section__body">
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
</div>
</div>
</div>
<div class="medium-12 columns">
<div class="section">
<div class="medium-6 columns">
<div class="section" data-type="private">
<div class="section__header">
<h1 class="section__title">{{ _('Contest Clarifications') }}</h1>
<h1 class="section__title">{{ _('Materials') }}({{ _('Only Partic.') }})</h1>
<div class="section__tools">
<a href="#reply_or_broadcast" class="primary rounded button" name="broadcast" data-title="{{ _('Send Broadcast Message') }}" data-did="">{{ _('Send Broadcast Message') }}</a>
<button class="primary rounded button" name="upload_file">{{ _('Upload File') }}</button>
</div>
</div>
{% set files = tdoc.privateFiles %}
{% set filetype = "private" %}
{% include "partials/files.html" %}
<div class="section__body">
{% if not tcdocs.length %}
{{ nothing.render('Oh, there is no clarification!') }}
{% else %}
<ul class="dczcomments__list">
{% for doc in tcdocs %}
<li class="dczcomments__item" id="clarification_{{ doc._id }}" data-did="{{ doc._id }}">
<div class="media">
<div class="media__body top" style="max-width:100%">
<div class="clearfix">
<div class="supplementary dczcomments__supplementary">
{{_('Subject') }}: {{ contest.render_clarification_subject(tdoc,pdict,doc.subject) }} | {% if doc.owner == 0 %}<b>{{ _('Jury') }}</b>{% else %}{{ user.render_inline(udict[doc.owner], badge=false) }}{% endif %} @ {{ datetimeSpan(doc._id)|safe }}
</div>
{% if doc.owner %}
<div class="dczcomments__operations nojs--hide">
<a href="#reply_or_broadcast" name="reply" data-title="{{ _('Reply') }}#{{ doc._id }}" data-did="{{ doc._id }}"
><span class="icon icon-reply"></span>{{ _('Reply') }}</a>
</div>
{% endif %}
</div>
<div class="typo richmedia" data-emoji-enabled>
{{ doc['content']|markdown|safe }}
</div>
</div>
</div>
<ul class="dczcomments__replies">
{%- for rdoc in doc['reply'] -%}
<li class="dczcomments__reply">
<div class="media">
<div class="media__left top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="media__body top">
<div class="clearfix">
<div class="supplementary dczcomments__supplementary">
<b>{{ _('Jury') }}</b>
</div>
</div>
<div class="typo richmedia" data-emoji-enabled>
{{ rdoc['content']|markdown|safe }}
</div>
</div>
</div>
</li>
{%- endfor -%}
</ul>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
<div id="reply_or_broadcast">
<div class="section__header">
<h1 class="section__title">{{ _('Send Broadcast Message') }}</h1>
</div>
<div class="section__body typo">
<form method="post">
<div class="clarification-container"></div>
<input type="hidden" name="operation" value="clarification">
<input type="hidden" name="did" value="">
<div class="row">
<div class="medium-12 columns form__item_subject">
<label>
{{ _('Subject') }}
<select name="subject" class="select">
<option value="0">{{ _('General Issue') }}</option>
<option value="-1">{{ _('Technical Issue') }}</option>
{% for pid in tdoc.pids %}
<option value="{{ pid }}">{{ utils.getAlphabeticId(loop.index0) }}. {{ pdict[pid].title }}</option>
{% endfor %}
</select>
</label>
</div>
<div class="medium-12 columns form__item">
<label>
{{ _('Content') }}
<textarea name="content" class="textbox" data-markdown required></textarea>
</label>
</div>
</div>
<button type="submit" class="rounded primary button">{{ _('Submit') }}</button>
</div>
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
</div>
</div>
</div>
@@ -87,9 +87,9 @@
</div>
<div class="section__body no-padding">
{% if not canViewRecord %}
{{ nothing.render('According to the contest rules, you cannot view your submission details at current.') }}
{{ nothing.render('According to the contest rules, you cannot view your submission details at current.', compact=true) }}
{% elif not rdocs.length %}
{{ nothing.render('Oh, there is no submission!') }}
{{ nothing.render('Oh, there is no submission!', compact=true) }}
{% else %}
<table class="data-table record_main__table">
<colgroup>
@@ -129,7 +129,7 @@
</div>
<div class="section__body">
{% if not tcdocs.length %}
{{ nothing.render('Oh, there is no clarification!') }}
{{ nothing.render('Oh, there is no clarification!', compact=true) }}
{% else %}
<ul class="dczcomments__list">
{% for doc in tcdocs %}
@@ -203,6 +203,20 @@
</div>
</div>
<div class="medium-3 columns" data-sticky="large">
{% if tdoc.privateFiles.length %}
<div class="section side">
<div class="section__header">
<h1 class="section__title">{{_('Materials')}}</h1>
</div>
<ol>
{% for file in tdoc.privateFiles %}
<li class="menu__item">
<a class="menu__link" href="{{ url('contest_file_download', { tid: tdoc.docId, filename: file.name, type: 'private' }) }}">{{ file.name }}</a>
</li>
{% endfor %}
</ol>
</div>
{% endif %}
{% set owner_udoc = udict[tdoc.owner] %}
{% include "partials/contest_sidebar.html" %}
</div>
@@ -29,6 +29,9 @@
<li class="menu__item"><a class="menu__link" href="{{ url('contest_balloon', tid=tdoc.docId) }}">
<span class="icon icon-balloon"></span> {{ _('Balloon Status') }}
</a></li>
<li class="menu__item"><a class="menu__link" href="{{ url('contest_clarification', tid=tdoc.docId) }}">
<span class="icon icon-comment--text"></span> {{ _('Contest Clarifications') }}
</a></li>
<li class="menu__seperator"></li>
</ol>
</div>
@@ -1,44 +1,49 @@
{% import "components/nothing.html" as nothing with context %}
<div class="section__body no-padding files" data-fragment-id="files">
<div class="section__body no-padding files" {% if filetype %}data-type="{{ filetype }}"{% endif %} data-fragment-id="files{% if filetype %}-{{ filetype }}{% endif %}">
{% if files.length %}
<table class="data-table">
<colgroup>
<col class="col--checkbox">
{% if not sidebar %}<col class="col--checkbox">{% endif %}
<col class="col--name">
<col class="col--size">
<col class="col--operation">
</colgroup>
<thead>
<tr>
{% if not sidebar %}
<th class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" name="select_all" data-checkbox-toggle="files">
<input type="checkbox" name="select_all" data-checkbox-toggle="{{ filetype|default('files') }}">
</label>
</th>
{% endif %}
<th class="col--name">{{ _('Filename') }}</th>
<th class="col--size">{{ _('Size') }}</th>
<th class="col--operation"></th>
<th class="col--operation"><span class="icon icon-wrench"></span></th>
</tr>
</thead>
<tbody>
{%- for file in files -%}
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
{% if not sidebar %}
<td class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" data-checkbox-group="files" data-checkbox-range>
<input type="checkbox" data-checkbox-group="{{ filetype|default('files') }}" data-checkbox-range>
</label>
</td>
{% endif %}
<td class="col--name" data-preview>
<a href="{{ urlForFile(file.name) }}">{{ file.name }}</a>
<a href="{{ urlForFile(file.name, filetype) }}">{{ file.name }}</a>
</td>
<td class="col--size">{{ size(file.size) }}</td>
<td class="col--operation">
<a href="{{ urlForFile(file.name) }}" class="icon icon-download"></a>
<a href="{{ urlForFile(file.name, filetype) }}" class="icon icon-download"></a>
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
{% else %}
{{ nothing.render('There are no files currently.') }}
{{ nothing.render('There are no files currently.', compact=true) }}
{% endif %}
</div>
@@ -1,7 +1,7 @@
{% import "components/nothing.html" as nothing with context %}
{% set _files = testdata if filetype == 'testdata' else additional_file %}
<div class="section__body no-padding problem-{{ 'sidebar' if sidebar else 'files' }}-{{ filetype }}" data-fragment-id="problem-files-{{ filetype }}"
{% if sidebar %}data-type="{{ filetype }}" data-sidebar{% endif %}>
<div class="section__body files no-padding problem-{{ 'sidebar' if sidebar else 'files' }}-{{ filetype }}" data-fragment-id="problem-files-{{ filetype }}"
data-type="{{ filetype }}" {% if sidebar %}data-sidebar{% endif %}>
{% if reference %}
<blockquote class="note">
<p>{{ _('This is a copy of another problem.') }}</p>
@@ -49,8 +49,8 @@
<td class="col--size">{{ size(file.size) }}</td>
{% if can_edit %}
<td class="col--operation">
<a href="javascript:;" name="{{ filetype }}__rename"><span class="icon icon-edit"></span></a>
<a href="javascript:;" name="{{ filetype }}__delete"><span class="icon icon-delete"></span></a>
<a href="javascript:;" name="file_rename"><span class="icon icon-edit"></span></a>
<a href="javascript:;" name="file_remove"><span class="icon icon-delete"></span></a>
</td>
{% endif %}
</tr>
@@ -92,20 +92,13 @@
</div>
</div>
{% if page_name == 'problem_edit' %}
<div class="section side">
<div class="section side" data-type="additional_file" data-sidebar>
<div class="section__header">
<h1 class="section__title">{{ additional_file.length|default(0) }} {{_('Additional File')}}</h1>
<h1 class="section__title">{{_('Additional Files')}}</h1>
<div class="section__tools">
<button class="primary rounded button" name="upload_file">{{ _('Upload') }}</button>
</div>
</div>
<ol class="menu">
<li class="menu__item flex-row">
<a class="menu__link half" href="javascript:;" name="additional_file__upload">
<span class="icon icon-upload"></span> {{ _('Upload') }}
</a>
<a class="menu__link half" href="javascript:;" name="additional_file__download">
<span class="icon icon-download"></span> {{ _('Download All') }}
</a>
</li>
</ol>
{% set sidebar = true %}
{% set can_edit = true %}
{% set filetype = "additional_file" %}
@@ -2,7 +2,7 @@
{% extends "layout/basic.html" %}
{% block content %}
<div class="row">
<div class="medium-5 columns">
<div class="medium-5 columns" data-type="testdata">
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Testdata') }}</h1>
@@ -10,7 +10,7 @@
{% if not reference and (handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM)) %}
<a href="{{ url('problem_config', pid=pdoc.docId) }}" class="primary rounded button">{{ _('Config') }}</a>
<button class="primary rounded button" name="create_testdata">{{ _('Create') }}</button>
<button class="primary rounded button" name="upload_testdata">{{ _('Upload') }}</button>
<button class="primary rounded button" name="upload_file">{{ _('Upload') }}</button>
{% elif reference %}
<a href="{{ url('problem_detail', domainId=pdoc.reference.domainId, pid=pdoc.reference.pid) }}" class="primary rounded button">{{ _('Source') }}</a>
{% endif %}
@@ -22,10 +22,10 @@
{% include "partials/problem_files.html" %}
{% if not reference and (handler.user.own(pdoc) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA)) %}
<div class="section__body">
<button class="rounded button" name="download_selected_testdata">{{ _('Download Selected') }}</button>
<button class="rounded button" name="download_selected">{{ _('Download Selected') }}</button>
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
<button class="rounded button" name="remove_selected_testdata">{{ _('Remove Selected') }}</button>
<button class="rounded button" name="rename_selected_testdata">{{ _('Rename Selected') }}</button>
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
<button class="rounded button" name="rename_selected">{{ _('Rename Selected') }}</button>
{% endif %}
</div>
{% endif %}
@@ -61,14 +61,14 @@
</div>
{% endif %}
</div>
<div class="medium-4 columns">
<div class="medium-4 columns" data-type="additional_file">
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Files') }}</h1>
<h1 class="section__title">{{ _('Additional Files') }}</h1>
<div class="section__tools">
{% if (handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM)) and not reference %}
<button class="primary rounded button" name="create_file">{{ _('Create File') }}</button>
<button class="primary rounded button" name="upload_file">{{ _('Upload File') }}</button>
<button class="primary rounded button" name="create_file">{{ _('Create') }}</button>
<button class="primary rounded button" name="upload_file">{{ _('Upload') }}</button>
{% endif %}
</div>
</div>
@@ -76,10 +76,10 @@
{% set can_edit = (handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM)) and not reference %}
{% include "partials/problem_files.html" %}
<div class="section__body">
<button class="rounded button" name="download_selected_file">{{ _('Download Selected') }}</button>
<button class="rounded button" name="download_selected">{{ _('Download Selected') }}</button>
{% if (handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM)) and not reference %}
<button class="rounded button" name="remove_selected_file">{{ _('Remove Selected') }}</button>
<button class="rounded button" name="rename_selected_file">{{ _('Rename Selected') }}</button>
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
<button class="rounded button" name="rename_selected">{{ _('Rename Selected') }}</button>
{% endif %}
</div>
</div>