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

User: Odkazy na diplomy z účastnické hlavní stránky

parent c186eb79
Branches
No related tags found
1 merge request!137Sazba diplomů
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<th>Stav soutěže <th>Stav soutěže
<th>Odkazy <th>Odkazy
<tbody> <tbody>
{% for pion, contest, round in pions %} {% for pion, contest, round, certs in pions %}
{% set state = contest.ct_state() %} {% set state = contest.ct_state() %}
<tr> <tr>
<td class="text-center"><b>{{ round.category }}</b> <td class="text-center"><b>{{ round.category }}</b>
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
{% if contest.ct_state() in [RoundState.graded, RoundState.closed] and contest.scoretable_id %} {% if contest.ct_state() in [RoundState.graded, 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> <a class='btn btn-xs btn-success' href="{{ url_for('user_contest_score', id=contest.contest_id) }}">Výsledková listina</a>
{% endif %} {% endif %}
{% if certs %}
<a class='btn btn-xs btn-success' href="{{ url_for('user_contest_certificates', id=contest.contest_id) }}">Diplomy</a>
{% endif %}
{% endfor %} {% endfor %}
</table> </table>
{% else %} {% else %}
......
...@@ -12,7 +12,7 @@ import hmac ...@@ -12,7 +12,7 @@ import hmac
import os import os
import pikepdf import pikepdf
from pikepdf.models.metadata import encode_pdf_date from pikepdf.models.metadata import encode_pdf_date
from sqlalchemy import and_ from sqlalchemy import and_, func
from sqlalchemy.dialects.postgresql import insert as pgsql_insert from sqlalchemy.dialects.postgresql import insert as pgsql_insert
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
...@@ -50,11 +50,17 @@ def user_index(): ...@@ -50,11 +50,17 @@ def user_index():
) )
def load_pcrs() -> List[Tuple[db.Participation, db.Contest, db.Round]]: def load_pcrs() -> List[Tuple[db.Participation, db.Contest, db.Round, int]]:
return (db.get_session().query(db.Participation, db.Contest, db.Round) cert_subq = (db.get_session()
.query(db.Certificate.user_id, db.Certificate.cert_set_id, func.count(db.Certificate.type).label('count'))
.group_by(db.Certificate.user_id, db.Certificate.cert_set_id)
.subquery())
return (db.get_session().query(db.Participation, db.Contest, db.Round, cert_subq.c.count)
.select_from(db.Participation) .select_from(db.Participation)
.join(db.Contest, db.Contest.master_contest_id == db.Participation.contest_id) .join(db.Contest, db.Contest.master_contest_id == db.Participation.contest_id)
.join(db.Round) .join(db.Round)
.outerjoin(cert_subq, and_(cert_subq.c.user_id == db.Participation.user_id,
cert_subq.c.cert_set_id == db.Participation.contest_id))
.filter(db.Participation.user == g.user) .filter(db.Participation.user == g.user)
.filter(db.Round.year == config.CURRENT_YEAR) .filter(db.Round.year == config.CURRENT_YEAR)
.options(joinedload(db.Contest.place)) .options(joinedload(db.Contest.place))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment