diff --git a/mo/web/org_place.py b/mo/web/org_place.py index 34fb5895887672b79a7583f4b71d6084103fa333..a1bd66178175da146ffbb4d8e6769cf962c71886 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 1ea0de7c607807c14ff3e45a4ee4c86ab5828329..94f8df8e77ba0934a3043812c5f5f33ef4d133c2 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 %}