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
Branches
No related tags found
No related merge requests found
This commit is part of merge request !105. Comments created here will be created in the context of that merge request.
...@@ -87,6 +87,7 @@ class ScoreTask: ...@@ -87,6 +87,7 @@ class ScoreTask:
class Score: class Score:
round: db.Round round: db.Round
contest: Optional[db.Contest] contest: Optional[db.Contest]
hier_place: Optional[db.Place]
part_states: List[db.PartState] part_states: List[db.PartState]
want_successful: bool want_successful: bool
want_winners: bool want_winners: bool
...@@ -104,12 +105,13 @@ class Score: ...@@ -104,12 +105,13 @@ class Score:
_messages: List[Tuple[str, str]] _messages: List[Tuple[str, str]]
def __init__( 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 # Ze kterých stavů chceme výsledkovku počítat
part_states: List[db.PartState] = [db.PartState.registered, db.PartState.active], part_states: List[db.PartState] = [db.PartState.registered, db.PartState.active],
): ):
self.round = round self.round = round
self.contest = contest self.contest = contest
self.hier_place = hier_place
self.part_states = part_states self.part_states = part_states
self.want_successful = round.score_successful_limit is not None self.want_successful = round.score_successful_limit is not None
self.want_winners = round.score_winner_limit is not None self.want_winners = round.score_winner_limit is not None
...@@ -121,6 +123,10 @@ class Score: ...@@ -121,6 +123,10 @@ class Score:
contest_subq = [contest.master_contest_id] contest_subq = [contest.master_contest_id]
else: else:
contest_subq = sess.query(db.Contest.master_contest_id).filter_by(round=round) 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ů # Načtení účastníků
data: List[Tuple[db.User, db.Participation, db.Participant]] = ( data: List[Tuple[db.User, db.Participation, db.Participant]] = (
......
...@@ -86,10 +86,12 @@ class ScoreEditForm(FlaskForm): ...@@ -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')
@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>/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')
@app.route('/org/contest/c/<int:ct_id>/score/edit', methods=('GET', 'POST'), endpoint="org_score_edit") @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): 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, ct_id=ct_id) ctx = get_context(round_id=round_id, hier_id=hier_id, ct_id=ct_id)
contest = ctx.contest contest = ctx.contest
round = ctx.round round = ctx.round
format = request.args.get('format', "") format = request.args.get('format', "")
...@@ -106,7 +108,7 @@ def org_score(round_id: Optional[int] = None, ct_id: Optional[int] = None): ...@@ -106,7 +108,7 @@ def org_score(round_id: Optional[int] = None, ct_id: Optional[int] = None):
if is_edit and not can_manage: if is_edit and not can_manage:
raise werkzeug.exceptions.Forbidden() raise werkzeug.exceptions.Forbidden()
score = Score(round.master, contest) score = Score(round.master, contest, ctx.hier_place)
tasks = score.get_tasks() tasks = score.get_tasks()
results = score.get_sorted_results() results = score.get_sorted_results()
messages = score.get_messages() messages = score.get_messages()
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
{% if can_view_contestants %} {% if can_view_contestants %}
<a class="btn btn-primary" href='{{ ctx.url_for('org_generic_list') }}'>Seznam účastníků</a> <a class="btn btn-primary" href='{{ ctx.url_for('org_generic_list') }}'>Seznam účastníků</a>
{% endif %} {% 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> <a class="btn btn-primary" href='{{ ctx.url_for('org_score') }}'>Výsledky</a>
{% endif %} {% endif %}
{% if can_manage_contest %} {% if can_manage_contest %}
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
{% block title %} {% block title %}
{{ round.round_code() }}: Výsledky pro {{ round.name|lower }} kategorie {{ round.category }}{% if contest %} {{ contest.place.name_locative() }}{% endif %} {{ 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 %} {% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
{{ ctx.breadcrumbs(action="Výsledky oblasti" if contest else "Výsledky kola") }} {{ 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 to comment