Skip to content
Snippets Groups Projects
Commit a9a042d9 authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Contest: Účastníky lze vylistovat všude, akce jen s právy

parent 52a1592b
Branches
No related tags found
2 merge requests!10Nastavení kol a úloh,!9WIP: Zárodek uživatelské části webu a submitování
This commit is part of merge request !10. Comments created here will be created in the context of that merge request.
......@@ -182,7 +182,7 @@ def get_contest(id: int) -> db.Contest:
return contest
def get_contest_rr(id: int, right_needed: Optional[mo.rights.Right]) -> Tuple[db.Contest, mo.rights.Rights]:
def get_contest_rr(id: int, right_needed: Optional[mo.rights.Right] = None) -> Tuple[db.Contest, mo.rights.Rights]:
contest = get_contest(id)
rr = mo.rights.Rights(g.user)
......@@ -248,7 +248,8 @@ def org_contest_import_template():
@app.route('/org/contest/c/<int:id>/ucastnici', methods=('GET', 'POST'))
def org_contest_list(id: int):
contest, rr = get_contest_rr(id, mo.rights.Right.manage_contest)
contest, rr = get_contest_rr(id)
can_edit = rr.have_right(mo.rights.Right.manage_contest)
format = request.args.get('format', "")
filter = ParticipantsFilterForm(request.args)
......@@ -261,6 +262,8 @@ def org_contest_list(id: int):
participation_state=None if filter.participation_state.data == '*' else filter.participation_state.data
)
action_form = None
if can_edit:
action_form = ParticipantsActionForm()
if action_form.do_action(round=contest.round, rights=rr, query=query):
# Action happened, redirect
......@@ -270,7 +273,7 @@ def org_contest_list(id: int):
count = query.count()
if format == "":
table = make_contestant_table(query, add_checkbox=True)
table = make_contestant_table(query, add_checkbox=can_edit)
return render_template(
'org_contest_list.html',
contest=contest,
......
......@@ -14,9 +14,10 @@
<tr><td>Konec pro dozor<td>{{ contest.round.pr_submit_end|timeformat }}
</table>
<p><a href='{{ url_for('org_contest_list', id=contest.contest_id) }}'>Seznam účastníků</a>
{% if can_manage %}
<p><a href='{{ url_for('org_contest_import', id=contest.contest_id) }}'>Importovat účastníky</a>
<p><a href='{{ url_for('org_contest_list', id=contest.contest_id) }}'>Seznam účastníků</a>
<p><a href='{{ url_for('org_proctor_import', id=contest.contest_id) }}'>Importovat dozor</a>
{% endif %}
......
......@@ -38,4 +38,7 @@
{% include 'parts/org_participants_table_actions.html' %}
<hr>
<i>Upozornění: Můžete editovat jen účastníky soutěžící v oblastech, ke kterým máte právo.</i>
{% endblock %}
{% if action_form %}
<form action="" method="POST" class="form form-horizontal" role="form">
{{ table.to_html() }}
......@@ -41,3 +42,7 @@
<div class="col-sm-4">{{ wtf.form_field(action_form.remove_participation, form_type='inline', class='btn btn-danger') }}</div>
</div>
</form>
{% else %}
{{ table.to_html() }}
<i>Nemáte právo k editaci účastníků v této oblasti.</i>
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment