From ea743f62e30db1ae5f638eb1c8ab2d7c4466bb37 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Mon, 12 Apr 2021 17:21:28 +0200 Subject: [PATCH] =?UTF-8?q?Na=20str=C3=A1nce=20kola=20si=20st=C4=9B=C5=BEu?= =?UTF-8?q?jeme,=20pokud=20soubor=20se=20zad=C3=A1n=C3=ADm=20neexistuje?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #208. --- mo/web/org_round.py | 1 + mo/web/templates/org_round.html | 4 +++- mo/web/util.py | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mo/web/org_round.py b/mo/web/org_round.py index 5966b90a..993c0904 100644 --- a/mo/web/org_round.py +++ b/mo/web/org_round.py @@ -231,6 +231,7 @@ def org_round(id: int): can_upload=rr.offer_upload_feedback(), can_view_statement=rr.can_view_statement(), can_add_contest=g.gatekeeper.rights_generic().have_right(Right.add_contest), + statement_exists=mo.web.util.task_statement_exists(round), ) diff --git a/mo/web/templates/org_round.html b/mo/web/templates/org_round.html index 83aebd0a..9648bb8b 100644 --- a/mo/web/templates/org_round.html +++ b/mo/web/templates/org_round.html @@ -45,7 +45,9 @@ <tr><td>Dozor odevzdává do<td>{{ round.pr_submit_end|time_and_timedelta }} <tr><td>Zadání<td> {% if round.tasks_file %} - {% if can_view_statement %} + {% if not statement_exists %} + <span class=error>soubor neexistuje</span> + {% elif can_view_statement %} <a href='{{ url_for('org_task_statement', id=round.round_id) }}'>stáhnout</a> {% else %} není dostupné diff --git a/mo/web/util.py b/mo/web/util.py index 482e0de8..4f10a68d 100644 --- a/mo/web/util.py +++ b/mo/web/util.py @@ -42,6 +42,13 @@ class PagerForm(FlaskForm): return (count, query) +def task_statement_exists(round: db.Round) -> bool: + if round.tasks_file is None: + return False + file = os.path.join(mo.util.data_dir('statements'), round.tasks_file) + return os.path.isfile(file) + + def send_task_statement(round: db.Round) -> Response: assert round.tasks_file is not None file = os.path.join(mo.util.data_dir('statements'), round.tasks_file) -- GitLab