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

Org stránky soutěže, výpisu účastníků a tabulky řešení zdvojeny i pro konkrétní soutěžní místo

Na stránku soutěže zároveň přidán výpis soutěžních míst a přeformátovány
odkazy.
parent 1618bd50
Branches
No related tags found
2 merge requests!13Tabulky řešení,!9WIP: Zárodek uživatelské části webu a submitování
...@@ -198,15 +198,52 @@ def get_contest_rr(id: int, right_needed: Optional[Right] = None) -> Tuple[db.Co ...@@ -198,15 +198,52 @@ def get_contest_rr(id: int, right_needed: Optional[Right] = None) -> Tuple[db.Co
return contest, rr return contest, rr
def get_contest_site_rr(id: int, site_id: Optional[int], right_needed: Optional[Right] = None) -> Tuple[db.Contest, db.Place, Rights]:
if site_id is None:
contest, rr = get_contest_rr(id, right_needed)
return contest, None, rr
contest = get_contest(id)
site = db.get_session().query(db.Place).get(site_id)
if not site:
raise werkzeug.exceptions.NotFound()
rr = Rights(g.user)
rr.get_for_contest_site(contest, site)
if not (right_needed is None or rr.have_right(right_needed)):
raise werkzeug.exceptions.Forbidden()
return contest, site, rr
@app.route('/org/contest/c/<int:id>') @app.route('/org/contest/c/<int:id>')
def org_contest(id: int): @app.route('/org/contest/c/<int:id>/site/<int:site_id>/')
contest, rr = get_contest_rr(id, None) def org_contest(id: int, site_id: Optional[int] = None):
sess = db.get_session()
contest, site, rr = get_contest_site_rr(id, site_id, None)
tasks = sess.query(db.Task).filter_by(round=contest.round).all()
tasks.sort(key=lambda t: t.code)
count = None
places_counts = None
if site_id:
count = sess.query(db.Participation).filter_by(place_id=site_id).count()
else:
places_counts = (
sess.query(db.Place, func.count('*'))
.select_from(db.Participation).join(db.Place)
.group_by(db.Place)
.filter(db.Participation.contest_id == id).all()
)
return render_template( return render_template(
'org_contest.html', 'org_contest.html',
contest=contest, contest=contest, site=site,
rights=sorted(rr.current_rights, key=lambda r: r. name), rights=sorted(rr.current_rights, key=lambda r: r. name),
can_manage=rr.have_right(Right.manage_contest), can_manage=rr.have_right(Right.manage_contest),
tasks=tasks, places_counts=places_counts, count=count,
) )
...@@ -251,8 +288,9 @@ def org_contest_import_template(): ...@@ -251,8 +288,9 @@ def org_contest_import_template():
@app.route('/org/contest/c/<int:id>/ucastnici', methods=('GET', 'POST')) @app.route('/org/contest/c/<int:id>/ucastnici', methods=('GET', 'POST'))
def org_contest_list(id: int): @app.route('/org/contest/c/<int:id>/site/<int:site_id>/ucastnici', methods=('GET', 'POST'))
contest, rr = get_contest_rr(id) def org_contest_list(id: int, site_id: Optional[int] = None):
contest, site, rr = get_contest_site_rr(id, site_id)
can_edit = rr.have_right(Right.manage_contest) can_edit = rr.have_right(Right.manage_contest)
format = request.args.get('format', "") format = request.args.get('format', "")
...@@ -262,7 +300,7 @@ def org_contest_list(id: int): ...@@ -262,7 +300,7 @@ def org_contest_list(id: int):
round=contest.round, contest=contest, round=contest.round, contest=contest,
school=db.get_place_by_code(filter.school.data), school=db.get_place_by_code(filter.school.data),
# contest_place=db.get_place_by_code(filter.contest_place.data), # contest_place=db.get_place_by_code(filter.contest_place.data),
participation_place=db.get_place_by_code(filter.participation_place.data), participation_place=site if site else db.get_place_by_code(filter.participation_place.data),
participation_state=None if filter.participation_state.data == '*' else filter.participation_state.data participation_state=None if filter.participation_state.data == '*' else filter.participation_state.data
) )
...@@ -280,7 +318,7 @@ def org_contest_list(id: int): ...@@ -280,7 +318,7 @@ def org_contest_list(id: int):
table = make_contestant_table(query, add_checkbox=can_edit) table = make_contestant_table(query, add_checkbox=can_edit)
return render_template( return render_template(
'org_contest_list.html', 'org_contest_list.html',
contest=contest, contest=contest, site=site,
table=table, table=table,
filter=filter, count=count, action_form=action_form, filter=filter, count=count, action_form=action_form,
) )
...@@ -372,10 +410,9 @@ def make_contestant_table(query: Query, add_checkbox: bool = False, add_contest_ ...@@ -372,10 +410,9 @@ def make_contestant_table(query: Query, add_checkbox: bool = False, add_contest_
@app.route('/org/contest/c/<int:id>/reseni') @app.route('/org/contest/c/<int:id>/reseni')
def org_contest_solutions(id: int): @app.route('/org/contest/c/<int:id>/site/<int:site_id>/reseni')
# FIXME: Práva? def org_contest_solutions(id: int, site_id: Optional[int] = None):
# FIXME: Hlavička stránky podle Jirkova předělání contest, site, rr = get_contest_site_rr(id, site_id, Right.manage_contest)
contest, rr = get_contest_rr(id, Right.manage_contest)
format = request.args.get('format', "") format = request.args.get('format', "")
sess = db.get_session() sess = db.get_session()
...@@ -441,7 +478,7 @@ def org_contest_solutions(id: int): ...@@ -441,7 +478,7 @@ def org_contest_solutions(id: int):
if format == "": if format == "":
return render_template( return render_template(
'org_contest_solutions.html', 'org_contest_solutions.html',
contest=contest, contest=contest, site=site,
table=table, table=table,
) )
else: else:
... ...
......
{% extends "base.html" %} {% extends "base.html" %}
{% block body %} {% block body %}
{% set round = contest.round %} {% set round = contest.round %}
{% set site_id = site.place_id if site else None %}
<h2> <h2>
<a href='{{ url_for('org_round', id=round.round_id) }}'>Kolo {{ round.round_code() }}</a> <a href='{{ url_for('org_round', id=round.round_id) }}'>Kolo {{ round.round_code() }}</a>
{% if site %}
» <a href='{{ url_for('org_contest', id=contest.contest_id) }}'>{{ contest.place.name }}</a>
» soutěžní místo {{ site.name }}
{% else %}
» {{ contest.place.name }} » {{ contest.place.name }}
{% endif %}
</h2> </h2>
<table class=data> <table class=data>
<tr><td>Název<td>{{ round.name }} <tr><td>Název<td>{{ round.name }}
<tr><td>Oblast<td><a href='{{ url_for('org_place', id=contest.place.place_id) }}'>{{ contest.place.name }}</a> <tr><td>Oblast<td><a href='{{ url_for('org_place', id=contest.place.place_id) }}'>{{ contest.place.name }}</a>
{% if site %}
<tr><td>Soutěžní místo<td><a href='{{ url_for('org_place', id=site.place_id) }}'>{{ site.name }}</a>
{% endif %}
<tr><td>Stav<td class='rstate-{{round.state.name}}'>{{ round.state.friendly_name() }} <tr><td>Stav<td class='rstate-{{round.state.name}}'>{{ round.state.friendly_name() }}
</table> </table>
<p><a href='{{ url_for('org_contest_list', id=contest.contest_id) }}'>Seznam účastníků</a>
<p><a href='{{ url_for('org_contest_solutions', id=contest.contest_id) }}'>Odevzdaná řešení</a>
{% if can_manage %}
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-default" href='{{ url_for('org_contest_list', id=contest.contest_id, site_id=site_id) }}'>Seznam účastníků</a>
<a class="btn btn-default" href='{{ url_for('org_contest_solutions', id=contest.contest_id, site_id=site_id) }}'>Tabulka řešení</a>
{% if not site and can_manage %}
<a class="btn btn-primary" href='{{ url_for('org_contest_import', id=contest.contest_id) }}'>Importovat účastníky</a> <a class="btn btn-primary" href='{{ url_for('org_contest_import', id=contest.contest_id) }}'>Importovat účastníky</a>
<a class="btn btn-primary" href='{{ url_for('org_proctor_import', id=contest.contest_id) }}'>Importovat dozor</a> <a class="btn btn-primary" href='{{ url_for('org_proctor_import', id=contest.contest_id) }}'>Importovat dozor</a>
{% endif %}
</div> </div>
{% if not site %}
<h3>Soutěžní místa</h3>
{% if places_counts %}
<table class=data>
<thead>
<tr><th>Místo<th>Počet účastníků
</thead>
{% for (place, count) in places_counts %}
<tr>
<td><a href="{{ url_for('org_contest', id=contest.contest_id, site_id=place.place_id) }}">{{ place.name }}</a>
<td>{{ count }}
</tr>
{% endfor %}
</table>
{% else %}
<i>Žádní účastníci a žádná soutěžní místa.</i>
{% endif %}
{% endif %} {% endif %}
<h3>Úlohy</h3> <h3>Úlohy</h3>
...@@ -39,7 +66,7 @@ ...@@ -39,7 +66,7 @@
<td>{{ task.name }} <td>{{ task.name }}
<td>TODO počet <td>TODO počet
<td><div class="btn-group"> <td><div class="btn-group">
<a class="btn btn-xs btn-primary" href="{{ url_for('org_contest_task_submits', contest_id=contest.contest_id, task_id=task.task_id) }}">Odevzdaná řešení</a> <a class="btn btn-xs btn-primary" href="{{ url_for('org_contest_task_submits', contest_id=contest.contest_id, task_id=task.task_id, site_id=site_id) }}">Odevzdaná řešení</a>
</div> </div>
</tr> </tr>
{% endfor %} {% endfor %}
...@@ -48,7 +75,7 @@ ...@@ -48,7 +75,7 @@
<p>Zatím nebyly přidány žádné úlohy.</p> <p>Zatím nebyly přidány žádné úlohy.</p>
{% endif %} {% endif %}
<h3>Vaše práva k této soutěži</h3> <h3>Vaše práva k {% if site %}tomuto soutěžnímu místu{% else %}této soutěži{% endif %}</h3>
{% if rights %} {% if rights %}
<ul> <ul>
{% for r in rights %} {% for r in rights %}
... ...
......
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
<h2> <h2>
<a href='{{ url_for('org_round', id=contest.round_id) }}'>Kolo {{ contest.round.round_code() }}</a> <a href='{{ url_for('org_round', id=contest.round_id) }}'>Kolo {{ contest.round.round_code() }}</a>
» <a href="{{ url_for('org_contest', id=contest.contest_id) }}">{{ contest.place.name }}</a> » <a href="{{ url_for('org_contest', id=contest.contest_id) }}">{{ contest.place.name }}</a>
{% if site %} » <a href='{{ url_for('org_contest', id=contest.contest_id, site_id=site.place_id) }}'>soutěžní místo {{ site.name }}</a> {% endif %}
» Účastníci » Účastníci
</h2> </h2>
<form action="" method="GET" class="form form-inline" role="form"> <form action="" method="GET" class="form form-inline" role="form">
{% if not site %}
{{ wtf.form_field(filter.participation_place, placeholder='Kód / #ID', size=8) }} {{ wtf.form_field(filter.participation_place, placeholder='Kód / #ID', size=8) }}
{% endif %}
{{ wtf.form_field(filter.school, placeholder='Kód / #ID', size=8) }} {{ wtf.form_field(filter.school, placeholder='Kód / #ID', size=8) }}
{{ wtf.form_field(filter.participation_state) }} {{ wtf.form_field(filter.participation_state) }}
<div class="btn-group"> <div class="btn-group">
... ...
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
{% block body %} {% block body %}
{% set round = contest.round %} {% set round = contest.round %}
<h2> <h2>
<a href='{{ url_for('org_round', id=round.round_id) }}'>Kolo {{ round.round_code() }}</a> <a href='{{ url_for('org_round', id=contest.round_id) }}'>Kolo {{ contest.round.round_code() }}</a>
» {{ contest.place.name }} » <a href="{{ url_for('org_contest', id=contest.contest_id) }}">{{ contest.place.name }}</a>
{% if site %} » <a href='{{ url_for('org_contest', id=contest.contest_id, site_id=site.place_id) }}'>soutěžní místo {{ site.name }}</a> {% endif %}
» Tabulka řešení
</h2> </h2>
{{ table.to_html() }} {{ table.to_html() }}
... ...
......
...@@ -14,10 +14,8 @@ ...@@ -14,10 +14,8 @@
<tr><td>Dozor odevzdává do<td>{{ round.pr_submit_end|timeformat }} <tr><td>Dozor odevzdává do<td>{{ round.pr_submit_end|timeformat }}
</table> </table>
<p><a href='{{ url_for('org_round_list', id=round.round_id) }}'>Seznam účastníků</a>
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-default" href='{{ url_for('org_round_list', id=round.round_id) }}'>Seznam účastníků</a>
{% if can_manage_contestants %} {% if can_manage_contestants %}
<a class="btn btn-primary" href='{{ url_for('org_round_import', id=round.round_id) }}'>Importovat účastníky</a> <a class="btn btn-primary" href='{{ url_for('org_round_import', id=round.round_id) }}'>Importovat účastníky</a>
{% endif %} {% endif %}
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment