Skip to content
Snippets Groups Projects
Commit 7776e9f4 authored by Martin Mareš's avatar Martin Mareš
Browse files

fixup! Diplomy/UI: Přehled ocenění studentů pro školní garanty

parent ec0c2a11
No related branches found
No related tags found
No related merge requests found
......@@ -347,7 +347,8 @@ def org_school_results(school_id: int):
if place is None:
raise werkzeug.exceptions.NotFound()
if not g.gatekeeper.rights_for(place=place).have_right(Right.view_contestants):
# Úmyslně nekontrolujeme práva ke kategorii
if not g.gatekeeper.rights_for(place=place, year=config.CURRENT_YEAR).have_right(Right.view_contestants):
raise werkzeug.exceptions.Forbidden()
pants_subq = (sess.query(db.Participant.user_id)
......@@ -363,7 +364,7 @@ def org_school_results(school_id: int):
db.Participation.state == db.PartState.active)
.group_by(db.Contest.contest_id)
.all())
contest_ids = [cid for cid, cnt in contest_counts]
contest_ids = [cid for cid, _ in contest_counts]
num_pants_by_cid = {cid: cnt for cid, cnt in contest_counts}
contests = (sess.query(db.Contest)
......@@ -371,7 +372,6 @@ def org_school_results(school_id: int):
.options(joinedload(db.Contest.round))
.all())
contests.sort(key=lambda c: (c.round.category, c.round.seq)) # part nepotřebujeme, vše jsou hlavní soutěže
# FIXME: Vytřídit soutěže, na které nemám právo
cert_counts = (sess.query(db.CertFile.cert_set_id, db.CertFile.type, func.count(db.Certificate.user_id))
.select_from(db.Certificate)
......@@ -396,12 +396,12 @@ def org_school_results(school_id: int):
@app.route('/org/contest/school-results/')
def org_school_results_all():
sess = db.get_session()
school_place_ids = set(ur.place_id for ur in g.gatekeeper.roles if ur.role == db.RoleType.garant_skola)
if len(school_place_ids) == 1:
return redirect(url_for('org_school_results', school_id=list(school_place_ids)[0]))
sess = db.get_session()
schools = sess.query(db.Place).filter(db.Place.place_id.in_(school_place_ids)).all()
schools.sort(key=lambda p: locale.strxfrm(p.name))
# FIXME: Redirect, pokud je škola jen jedna
# FIXME: Drobečky
return render_template('org_school_results_all.html', schools=schools)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment