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

Na stránce kola si stěžujeme, pokud soubor se zadáním neexistuje

Closes #208.
parent bed79af5
No related branches found
No related tags found
No related merge requests found
...@@ -231,6 +231,7 @@ def org_round(id: int): ...@@ -231,6 +231,7 @@ def org_round(id: int):
can_upload=rr.offer_upload_feedback(), can_upload=rr.offer_upload_feedback(),
can_view_statement=rr.can_view_statement(), can_view_statement=rr.can_view_statement(),
can_add_contest=g.gatekeeper.rights_generic().have_right(Right.add_contest), can_add_contest=g.gatekeeper.rights_generic().have_right(Right.add_contest),
statement_exists=mo.web.util.task_statement_exists(round),
) )
......
...@@ -45,7 +45,9 @@ ...@@ -45,7 +45,9 @@
<tr><td>Dozor odevzdává do<td>{{ round.pr_submit_end|time_and_timedelta }} <tr><td>Dozor odevzdává do<td>{{ round.pr_submit_end|time_and_timedelta }}
<tr><td>Zadání<td> <tr><td>Zadání<td>
{% if round.tasks_file %} {% 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> <a href='{{ url_for('org_task_statement', id=round.round_id) }}'>stáhnout</a>
{% else %} {% else %}
není dostupné není dostupné
......
...@@ -42,6 +42,13 @@ class PagerForm(FlaskForm): ...@@ -42,6 +42,13 @@ class PagerForm(FlaskForm):
return (count, query) 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: def send_task_statement(round: db.Round) -> Response:
assert round.tasks_file is not None assert round.tasks_file is not None
file = os.path.join(mo.util.data_dir('statements'), round.tasks_file) file = os.path.join(mo.util.data_dir('statements'), round.tasks_file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment