From 658a072c564541545e6278e34562126f1d777a78 Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz> Date: Fri, 11 Jun 2021 22:45:33 +0200 Subject: [PATCH] =?UTF-8?q?Odkazy=20na=20sout=C4=9B=C5=BEe=20z=20m=C3=ADst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #213 --- mo/web/org_place.py | 10 +++++++++- mo/web/templates/org_place.html | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mo/web/org_place.py b/mo/web/org_place.py index 34fb5895..a1bd6617 100644 --- a/mo/web/org_place.py +++ b/mo/web/org_place.py @@ -32,11 +32,19 @@ def org_place(id: int): children = sorted(place.children, key=lambda p: locale.strxfrm(p.name)) rr = g.gatekeeper.rights_for(place) + contests = (sess.query(db.Contest) + .options(joinedload(db.Contest.round)) + .filter_by(place=place) + .all()) + + contests.sort(key=lambda c: (-c.round.year, c.round.category, c.round.seq, c.round.part)) + return render_template( 'org_place.html', place=place, school=school, can_edit=rr.can_edit_place(place), can_add_child=rr.can_add_place_child(place), - children=children + children=children, + contests=contests ) diff --git a/mo/web/templates/org_place.html b/mo/web/templates/org_place.html index 1ea0de7c..94f8df8e 100644 --- a/mo/web/templates/org_place.html +++ b/mo/web/templates/org_place.html @@ -55,4 +55,29 @@ <a class="btn btn-primary" href="{{ url_for('org_place_new_child', id=place.place_id) }}">Přidat nové podřízené místo</a> {% endif %} {% endif %} + +<h3>Soutěže</h3> + +{% if not contests %} +<p>K tomuto místu nejsou přidružené žádné soutěže. +{% else %} +<table class=data> + <thead><tr> + <th>ID + <th>Ročník + <th>Kat. + <th>Název + <th>Stav + </thead> + {% for c in contests %} + <tr> + {% set r = c.round %} + <td><a href='{{ url_for('org_contest', id=c.contest_id) }}'>{{ r.round_code() }}</a> + <td>{{ r.year }} + <td>{{ r.category }} + <td>{{ r.name }} + <td class='rstate-{{c.state.name}}'>{{ c.state.friendly_name() }} + {% endfor %} +</table> +{% endif %} {% endblock %} -- GitLab