Skip to content
Snippets Groups Projects
Commit 571849d5 authored by Jan Prachař's avatar Jan Prachař
Browse files

Oprava zobrazení tlačítek, na který nemá uživatel oprávnění

parent eaefb755
No related branches found
No related tags found
1 merge request!64Oprava zobrazení tlačítek, na který nemá uživatel oprávnění
...@@ -255,6 +255,9 @@ class RoundRights(Rights): ...@@ -255,6 +255,9 @@ class RoundRights(Rights):
def can_view_statement(self) -> bool: def can_view_statement(self) -> bool:
return self._check_view_statement(self.round) return self._check_view_statement(self.round)
def can_view_submits(self) -> bool:
return self.have_right(Right.view_submits)
class ContestRights(Rights): class ContestRights(Rights):
"""Práva k soutěži.""" """Práva k soutěži."""
...@@ -281,6 +284,9 @@ class ContestRights(Rights): ...@@ -281,6 +284,9 @@ class ContestRights(Rights):
def can_view_statement(self) -> bool: def can_view_statement(self) -> bool:
return self._check_view_statement(self.contest.round) return self._check_view_statement(self.contest.round)
def can_view_submits(self) -> bool:
return self.have_right(Right.view_submits)
class Gatekeeper: class Gatekeeper:
"""Dveřník rozhoduje, jaká práva má uživatel k danému objektu. """Dveřník rozhoduje, jaká práva má uživatel k danému objektu.
......
...@@ -372,6 +372,7 @@ def org_contest(id: int, site_id: Optional[int] = None): ...@@ -372,6 +372,7 @@ def org_contest(id: int, site_id: Optional[int] = None):
can_edit_points=rr.can_edit_points(), can_edit_points=rr.can_edit_points(),
can_create_solutions=rr.can_upload_feedback() or rr.can_upload_solutions(), can_create_solutions=rr.can_upload_feedback() or rr.can_upload_solutions(),
can_view_statement=rr.can_view_statement(), can_view_statement=rr.can_view_statement(),
can_view_submits=rr.can_view_submits(),
tasks=tasks, places_counts=places_counts, tasks=tasks, places_counts=places_counts,
) )
......
...@@ -167,7 +167,7 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool: ...@@ -167,7 +167,7 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool:
@app.route('/org/contest/r/<int:id>/', methods=('GET', 'POST')) @app.route('/org/contest/r/<int:id>/', methods=('GET', 'POST'))
def org_round(id: int): def org_round(id: int):
sess = db.get_session() sess = db.get_session()
round, _, rr = get_round_rr(id, None, True) round, _, rr = get_round_rr(id, None, False)
can_manage_round = rr.have_right(Right.manage_round) can_manage_round = rr.have_right(Right.manage_round)
can_manage_contestants = rr.have_right(Right.manage_contest) can_manage_contestants = rr.have_right(Right.manage_contest)
...@@ -228,6 +228,7 @@ def org_round(id: int): ...@@ -228,6 +228,7 @@ def org_round(id: int):
can_handle_submits=rr.have_right(Right.view_submits), can_handle_submits=rr.have_right(Right.view_submits),
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_view_submits=rr.can_view_submits(),
can_add_contest=g.gatekeeper.rights_generic().have_right(Right.add_contest), can_add_contest=g.gatekeeper.rights_generic().have_right(Right.add_contest),
) )
...@@ -335,7 +336,7 @@ def org_round_task_upload(round_id: int, task_id: int): ...@@ -335,7 +336,7 @@ def org_round_task_upload(round_id: int, task_id: int):
@app.route('/org/contest/r/<int:round_id>/task/<int:task_id>/batch-points', methods=('GET', 'POST')) @app.route('/org/contest/r/<int:round_id>/task/<int:task_id>/batch-points', methods=('GET', 'POST'))
def org_round_task_batch_points(round_id: int, task_id: int): def org_round_task_batch_points(round_id: int, task_id: int):
round, _, _ = get_round_rr(round_id, Right.edit_points, True) round, _, _ = get_round_rr(round_id, Right.edit_points, False)
task = get_task(round, task_id) task = get_task(round, task_id)
return generic_batch_points(round=round, contest=None, task=task) return generic_batch_points(round=round, contest=None, task=task)
......
...@@ -216,6 +216,7 @@ def org_score(round_id: Optional[int] = None, contest_id: Optional[int] = None): ...@@ -216,6 +216,7 @@ def org_score(round_id: Optional[int] = None, contest_id: Optional[int] = None):
contest=contest, round=round, tasks=tasks, contest=contest, round=round, tasks=tasks,
table=table, messages=messages, table=table, messages=messages,
group_rounds=group_rounds, group_rounds=group_rounds,
can_view_submits=rr.can_view_submits(),
) )
else: else:
return table.send_as(format) return table.send_as(format)
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-primary" href='{{ url_for('org_contest_list', id=contest.contest_id, site_id=site_id) }}'>Seznam účastníků</a> <a class="btn btn-primary" href='{{ url_for('org_contest_list', id=contest.contest_id, site_id=site_id) }}'>Seznam účastníků</a>
{% if round.state != RoundState.preparing %} {% if can_view_submits and round.state != RoundState.preparing %}
<a class="btn btn-primary" href='{{ url_for('org_contest_solutions', id=contest.contest_id, site_id=site_id) }}'>Odevzdaná řešení</a> <a class="btn btn-primary" href='{{ url_for('org_contest_solutions', id=contest.contest_id, site_id=site_id) }}'>Odevzdaná řešení</a>
{% endif %} {% endif %}
{% if not site %} {% if not site %}
...@@ -115,7 +115,9 @@ ...@@ -115,7 +115,9 @@
<td>{{ task.sol_count }} <td>{{ task.sol_count }}
<td>{{ task.max_points|none_value('–') }} <td>{{ task.max_points|none_value('–') }}
<td><div class="btn-group"> <td><div class="btn-group">
{% if can_view_submits %}
<a class="btn btn-xs btn-primary" href="{{ url_for('org_contest_task', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Odevzdaná řešení</a> <a class="btn btn-xs btn-primary" href="{{ url_for('org_contest_task', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Odevzdaná řešení</a>
{% endif %}
{% if not site and can_edit_points %} {% if not site and can_edit_points %}
<a class="btn btn-xs btn-default" href="{{ url_for('org_contest_task_points', contest_id=contest.contest_id, task_id=task.task_id) }}">Zadat body</a> <a class="btn btn-xs btn-default" href="{{ url_for('org_contest_task_points', contest_id=contest.contest_id, task_id=task.task_id) }}">Zadat body</a>
{% endif %} {% endif %}
...@@ -124,7 +126,9 @@ ...@@ -124,7 +126,9 @@
{% endif %} {% endif %}
</div> </div>
<td><div class="btn-group"> <td><div class="btn-group">
{% if can_view_submits %}
<a class="btn btn-xs btn-primary" href="{{ url_for('org_contest_task_download', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Stáhnout ZIP</a> <a class="btn btn-xs btn-primary" href="{{ url_for('org_contest_task_download', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Stáhnout ZIP</a>
{% endif %}
{% if can_upload %} {% if can_upload %}
<a class='btn btn-xs btn-default' href="{{ url_for('org_contest_task_upload', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Nahrát ZIP</a> <a class='btn btn-xs btn-default' href="{{ url_for('org_contest_task_upload', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Nahrát ZIP</a>
{% endif %} {% endif %}
......
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
<th>Odevzdaná řešení <th>Odevzdaná řešení
<th>Maximum bodů <th>Maximum bodů
{% if can_manage_round %}<th>Akce{% endif %} {% if can_manage_round %}<th>Akce{% endif %}
{% if can_handle_submits or can_upload %}<th>Dávkové operace{% endif %} {% if can_view_submits or can_upload %}<th>Dávkové operace{% endif %}
</tr> </tr>
</thead> </thead>
{% for task in tasks %} {% for task in tasks %}
...@@ -155,9 +155,9 @@ ...@@ -155,9 +155,9 @@
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
{% if can_handle_submits or can_upload %} {% if can_view_submits or can_upload %}
<td><div class="btn-group"> <td><div class="btn-group">
{% if can_handle_submits %} {% if can_view_submits %}
<a class="btn btn-xs btn-primary" href="{{ url_for('org_round_task_download', round_id=round.round_id, task_id=task.task_id) }}">Stáhnout ZIP</a> <a class="btn btn-xs btn-primary" href="{{ url_for('org_round_task_download', round_id=round.round_id, task_id=task.task_id) }}">Stáhnout ZIP</a>
{% endif %} {% endif %}
{% if can_upload %} {% if can_upload %}
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
{% block pretitle %} {% block pretitle %}
<div class="btn-group pull-right"> <div class="btn-group pull-right">
{% if contest %} {% if contest %}
{% if can_view_submits %}
<a class="btn btn-default" href="{{ url_for('org_contest_solutions', id=contest.contest_id) }}">Odevzdaná řešení</a> <a class="btn btn-default" href="{{ url_for('org_contest_solutions', id=contest.contest_id) }}">Odevzdaná řešení</a>
{% endif %}
<a class="btn btn-default" href="{{ url_for('org_score', round_id=round.round_id) }}">Výsledky kola</a> <a class="btn btn-default" href="{{ url_for('org_score', round_id=round.round_id) }}">Výsledky kola</a>
{% endif %} {% endif %}
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment