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

Zobrazení výsledkových listin pro soutěžící

Issue #209
parent f2bc8496
No related branches found
No related tags found
1 merge request!110Zveřejňování výsledkovky účastníkům
......@@ -71,6 +71,9 @@ Pokud si s tvorbou PDF nevíte rady, zkuste se podívat do <a href='https://docs
<p>Odevzdávání bylo ukončeno. Vyčkejte prosím, až úlohy opravíme.
{% elif state == RoundState.closed %}
<p>Soutěžní kolo bylo ukončeno, níže si můžete prohlédnout svá ohodnocená a okomentovaná řešení.
{% if contest.ct_state() == RoundState.closed and contest.scoretable_id %}
Také je již zveřejněna <strong><a href="{{ url_for('user_contest_score', id=contest.contest_id) }}">výsledková listina</a></strong>.
{% endif %}
{% else %}
<p>Soutěž se nachází v neznámém stavu. To by se nemělo stát :)
{% endif %}
......
{% extends "base.html" %}
{% set round = contest.round %}
{% block title %}Výsledky pro {{ round.name|lower }} {{ round.year }}. ročníku kategorie {{ round.category }}: {{ contest.place.name }}{% endblock %}
{% block breadcrumbs %}
<li><a href='{{ url_for('user_index') }}'>Soutěže</a>
<li><a href='{{ url_for('user_contest', id=contest.contest_id) }}'>{{ round.name }} {{ round.year }}. ročníku kategorie {{ round.category }}: {{ contest.place.name }}</a>
<li>Výsledky
{% endblock %}
{% block body %}
{{ table.to_html() }}
{% endblock %}
......@@ -36,6 +36,9 @@
Detail kola
{% endif %}
</a>
{% if contest.ct_state() == RoundState.closed and contest.scoretable_id %}
<a class='btn btn-xs btn-success' href="{{ url_for('user_contest_score', id=contest.contest_id) }}">Výsledková listina</a>
{% endif %}
{% endfor %}
</table>
{% else %}
......
......@@ -531,3 +531,35 @@ def scoretable_construct(scoretable: db.ScoreTable, is_export: bool = False) ->
table_rows.append(Row(keys=row, html_attr=html_attr))
return (columns, table_rows)
@app.route('/user/contest/<int:id>/score')
def user_contest_score(id: int):
contest, pion = get_contest_pion(id, require_reg=False)
round = contest.round
format = request.args.get('format', "")
# Výsledkovku zobrazíme jen pokud je soutěž již ukončená
state = contest.ct_state()
if not contest.scoretable or state != db.RoundState.closed:
raise werkzeug.exceptions.NotFound()
columns, table_rows = scoretable_construct(contest.scoretable, format != "")
# columns.append(Column(key='order_key', name='order_key', title='Třídící klíč'))
filename = f"vysledky_{round.year}-{round.category}-{round.level}_oblast_{contest.place.code or contest.place.place_id}"
table = Table(
table_class="data full center",
columns=columns,
rows=table_rows,
filename=filename,
)
if format == "":
return render_template(
'user_contest_score.html',
contest=contest,
table=table,
)
else:
return table.send_as(format)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment