diff --git a/mo/web/org_round.py b/mo/web/org_round.py index 5966b90ad9fc07c2c1496500da501115f5528dd6..993c0904896bdbc4798f4513c41ae63d4ef3e440 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 83aebd0afd2136206d826303af70daf091be066b..9648bb8bc7e1631ede11d568919478d95c7ce82e 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 482e0de8b388cff99da6f2cae73bed6ec7b760d0..4f10a68d52fc20246453ea9ddf7b88a9f8a88ba5 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)