Skip to content
Snippets Groups Projects
Commit 38a4332b authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Výsledkovky i pro hierarchické procházení soutěží

Issue #238
parent 96fefcf8
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,7 @@ class ScoreTask:
class Score:
round: db.Round
contest: Optional[db.Contest]
hier_place: Optional[db.Place]
part_states: List[db.PartState]
want_successful: bool
want_winners: bool
......@@ -104,12 +105,13 @@ class Score:
_messages: List[Tuple[str, str]]
def __init__(
self, round: db.Round, contest: Optional[db.Contest] = None,
self, round: db.Round, contest: Optional[db.Contest] = None, hier_place: Optional[db.Place] = None,
# Ze kterých stavů chceme výsledkovku počítat
part_states: List[db.PartState] = [db.PartState.registered, db.PartState.active],
):
self.round = round
self.contest = contest
self.hier_place = hier_place
self.part_states = part_states
self.want_successful = round.score_successful_limit is not None
self.want_winners = round.score_winner_limit is not None
......@@ -121,6 +123,10 @@ class Score:
contest_subq = [contest.master_contest_id]
else:
contest_subq = sess.query(db.Contest.master_contest_id).filter_by(round=round)
if hier_place:
contest_subq = db.filter_place_nth_parent(
contest_subq, db.Contest.place_id, round.level - hier_place.level, hier_place.place_id
)
# Načtení účastníků
data: List[Tuple[db.User, db.Participation, db.Participant]] = (
......
......@@ -86,10 +86,12 @@ class ScoreEditForm(FlaskForm):
@app.route('/org/contest/r/<int:round_id>/score')
@app.route('/org/contest/r/<int:round_id>/score/edit', methods=('GET', 'POST'), endpoint="org_score_edit")
@app.route('/org/contest/r/<int:round_id>/h/<int:hier_id>/score')
@app.route('/org/contest/r/<int:round_id>/h/<int:hier_id>/score/edit', methods=('GET', 'POST'), endpoint="org_score_edit")
@app.route('/org/contest/c/<int:ct_id>/score')
@app.route('/org/contest/c/<int:ct_id>/score/edit', methods=('GET', 'POST'), endpoint="org_score_edit")
def org_score(round_id: Optional[int] = None, ct_id: Optional[int] = None):
ctx = get_context(round_id=round_id, ct_id=ct_id)
def org_score(round_id: Optional[int] = None, hier_id: Optional[int] = None, ct_id: Optional[int] = None):
ctx = get_context(round_id=round_id, hier_id=hier_id, ct_id=ct_id)
contest = ctx.contest
round = ctx.round
format = request.args.get('format', "")
......@@ -106,7 +108,7 @@ def org_score(round_id: Optional[int] = None, ct_id: Optional[int] = None):
if is_edit and not can_manage:
raise werkzeug.exceptions.Forbidden()
score = Score(round.master, contest)
score = Score(round.master, contest, ctx.hier_place)
tasks = score.get_tasks()
results = score.get_sorted_results()
messages = score.get_messages()
......
......@@ -88,7 +88,7 @@
{% if can_view_contestants %}
<a class="btn btn-primary" href='{{ ctx.url_for('org_generic_list') }}'>Seznam účastníků</a>
{% endif %}
{% if can_view_contestants and round.state in [RoundState.grading, RoundState.closed, RoundState.delegate] and not in_hier %}
{% if can_view_contestants and round.state in [RoundState.grading, RoundState.closed, RoundState.delegate] %}
<a class="btn btn-primary" href='{{ ctx.url_for('org_score') }}'>Výsledky</a>
{% endif %}
{% if can_manage_contest %}
......
......@@ -3,6 +3,7 @@
{% block title %}
{{ round.round_code() }}: Výsledky pro {{ round.name|lower }} kategorie {{ round.category }}{% if contest %} {{ contest.place.name_locative() }}{% endif %}
{% if ctx.hier_place %} ({{ ctx.hier_place.name_locative() }}){% endif %}
{% endblock %}
{% block breadcrumbs %}
{{ ctx.breadcrumbs(action="Výsledky oblasti" if contest else "Výsledky kola") }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment