From f1a5bf2d94ddfc304092dbc4f92a90a9c561c529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Setni=C4=8Dka?= <setnicka@seznam.cz> Date: Sat, 4 Dec 2021 21:45:36 +0100 Subject: [PATCH] =?UTF-8?q?Zobrazen=C3=AD=20v=C3=BDsledkov=C3=BDch=20listi?= =?UTF-8?q?n=20pro=20sout=C4=9B=C5=BE=C3=ADc=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #209 --- mo/web/templates/user_contest.html | 3 +++ mo/web/templates/user_contest_score.html | 15 +++++++++++ mo/web/templates/user_index.html | 3 +++ mo/web/user.py | 32 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 mo/web/templates/user_contest_score.html diff --git a/mo/web/templates/user_contest.html b/mo/web/templates/user_contest.html index 8d670b24..805ce489 100644 --- a/mo/web/templates/user_contest.html +++ b/mo/web/templates/user_contest.html @@ -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 %} diff --git a/mo/web/templates/user_contest_score.html b/mo/web/templates/user_contest_score.html new file mode 100644 index 00000000..a9d0b2f8 --- /dev/null +++ b/mo/web/templates/user_contest_score.html @@ -0,0 +1,15 @@ +{% 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 %} diff --git a/mo/web/templates/user_index.html b/mo/web/templates/user_index.html index 440b9a16..fb74e4d2 100644 --- a/mo/web/templates/user_index.html +++ b/mo/web/templates/user_index.html @@ -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 %} diff --git a/mo/web/user.py b/mo/web/user.py index 64ea0c49..3bdd3515 100644 --- a/mo/web/user.py +++ b/mo/web/user.py @@ -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) -- GitLab