Skip to content
Snippets Groups Projects
Commit 336084a3 authored by Martin Mareš's avatar Martin Mareš
Browse files

UI k uploadu feedbacku

parent 7fcaf0d7
No related branches found
No related tags found
3 merge requests!19Reforma vyhodnocování práv,!18Dávky okolo feedbacku,!17Výsledkovka pomocí mo.web.table
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
...@@ -189,7 +189,7 @@ class ParticipantsActionForm(FlaskForm): ...@@ -189,7 +189,7 @@ class ParticipantsActionForm(FlaskForm):
class DownloadButtonForm(FlaskForm): class DownloadButtonForm(FlaskForm):
download = wtforms.SubmitField('Stáhnout všechna řešení jako ZIP') download = wtforms.SubmitField('Stáhnout řešení jako ZIP')
download_feedback = wtforms.SubmitField('Stáhnout opravená jako ZIP') download_feedback = wtforms.SubmitField('Stáhnout opravená jako ZIP')
...@@ -872,3 +872,33 @@ def org_contest_solutions(id: int, site_id: Optional[int] = None): ...@@ -872,3 +872,33 @@ def org_contest_solutions(id: int, site_id: Optional[int] = None):
db=db, # kvůli hodnotám enumů db=db, # kvůli hodnotám enumů
download_form=download_form, download_form=download_form,
) )
class UploadFeedbackForm(FlaskForm):
file = flask_wtf.file.FileField("Soubor")
submit = wtforms.SubmitField('Odeslat')
@app.route('/org/contest/c/<int:id>/upload-feedback', methods=('GET', 'POST'))
def org_upload_feedback(id: int):
sc = get_solution_context(id, None, None, None)
if not sc.allow_upload_feedback:
raise werkzeug.exceptions.Forbidden()
form = UploadFeedbackForm()
if form.validate_on_submit():
# FIXME: Viz komentář o efektivitě v user_contest_task
tmp_name = secrets.token_hex(16)
tmp_path = os.path.join(app.instance_path, 'tmp', tmp_name)
form.file.data.save(tmp_path)
mo.jobs.submit.schedule_upload_feedback(sc.round, tmp_path, f'Nahrání opravených řešení {sc.round.round_code()}', g.user)
return redirect(url_for('org_jobs'))
return render_template(
'org_upload_feedback.html',
round=sc.round,
contest=sc.contest,
form=form,
)
...@@ -87,6 +87,6 @@ konkrétní úlohu. Symbol <b>+</b> značí, že existuje více verzí dostupný ...@@ -87,6 +87,6 @@ konkrétní úlohu. Symbol <b>+</b> značí, že existuje více verzí dostupný
{% endfor %} {% endfor %}
</table> </table>
{{ wtf.quick_form(download_form, form_type='basic') }} {% include "parts/org_sol_download.html" %}
{% endblock %} {% endblock %}
...@@ -89,6 +89,6 @@ naleznete v detailu řešení. ...@@ -89,6 +89,6 @@ naleznete v detailu řešení.
{% endfor %} {% endfor %}
</table> </table>
{{ wtf.quick_form(download_form, form_type='basic') }} {% include "parts/org_sol_download.html" %}
{% endblock %} {% endblock %}
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block body %}
<h2>
<a href='{{ url_for('org_round', id=round.round_id) }}'>Kolo {{ round.round_code() }}</a>
» <a href='{{ url_for('org_contest', id=contest.contest_id) }}'>{{ contest.place.name }}</a>
» Nahrát opravená řešení
</h2>
{{ wtf.quick_form(form, form_type='basic') }}
{% endblock %}
<form action="" method="POST" class="form form-basic" role="form">
{{ download_form.csrf_token }}
<div class="form-group">
{{ wtf.form_field(download_form.download, form_type='inline') }}
{{ wtf.form_field(download_form.download_feedback, form_type='inline') }}
{% if sc.site == None and sc.allow_upload_feedback %}
<a class='btn btn-default' href="{{ url_for('org_upload_feedback', id=sc.contest.contest_id) }}">Nahrát opravená řešení</a>
{% endif %}
</div>
</form>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment