diff --git a/bin/create-contests b/bin/create-contests index d7f6e2e912c7c423b645ddf8c4900744803f9afb..81c65c67bab373d4313971531abdfa5efe35f343 100755 --- a/bin/create-contests +++ b/bin/create-contests @@ -48,17 +48,20 @@ else: assert regions, "Neexistují žádná místa dané úrovně" for r in regions: - print(f"Zakládám {round.round_code()} pro místo {r.name}") - if not args.dry_run: - c = db.Contest(round=round, place=r, state=state) - - sess.add(c) - sess.flush() - c.master = c - - mo.util.log(db.LogType.contest, c.contest_id, { - 'action': 'created', - }) + if sess.query(db.Contest).filter_by(round=round, place=r).first(): + print(f"{round.round_code()} pro místo {r.name}: již existuje") + else: + print(f"{round.round_code()} pro místo {r.name}: zakládám") + if not args.dry_run: + c = db.Contest(round=round, place=r, state=state) + + sess.add(c) + sess.flush() + c.master = c + + mo.util.log(db.LogType.contest, c.contest_id, { + 'action': 'created', + }) if not args.dry_run: sess.commit() diff --git a/mo/web/templates/org_contest.html b/mo/web/templates/org_contest.html index b6f438df4dab6b1b1ba3c25f85b3675a97ab896d..198997bac804a1f68257c4ef3eacc0446f1472fa 100644 --- a/mo/web/templates/org_contest.html +++ b/mo/web/templates/org_contest.html @@ -7,6 +7,8 @@ {% set can_edit_points = not site and rights.can_edit_points() %} {% set can_create_solutions = rights.can_upload_feedback() or rights.can_upload_solutions() %} {% set can_view_statement = rights.can_view_statement() %} +{% set can_view_contestants = rights.have_right(Right.view_contestants) %} +{% set can_view_submits = rights.have_right(Right.view_submits) %} {% block title %} {{ round.round_code() }}: {% if site %}soutěžní místo {{ site.name }}{% else %}{{ contest.place.name }}{% endif %} @@ -53,37 +55,39 @@ {% endif %} </table> +{% if can_view_contestants or can_upload or can_manage %}{# Ostatní práva implikují některé z těchto #} <div class="btn-group"> + {% if can_view_contestants %} <a class="btn btn-primary" href='{{ ctx.url_for('org_generic_list') }}'>Seznam účastníků</a> - {% if state != RoundState.preparing %} + {% endif %} + {% if can_view_submits and state != RoundState.preparing %} <a class="btn btn-primary" href='{{ ctx.url_for('org_contest_solutions') }}'>Odevzdaná řešení</a> {% endif %} - {% if can_manage and site %} + {% if not site and can_manage %} <a class="btn btn-default" href="{{ ctx.url_for('org_contest_add_user') }}">Přidat účastníka</a> {% endif %} - {% if not site %} - {% if state in [RoundState.grading, RoundState.closed] %} + {% if not site and can_view_contestants and state in [RoundState.grading, RoundState.closed] %} <a class="btn btn-primary" href='{{ ctx.url_for('org_score') }}'>Výsledky</a> {% endif %} + {% if can_view_contestants %} <a class="btn btn-default" href='{{ ctx.url_for('org_contest_protocols') }}'>Protokoly</a> + {% endif %} {% if can_upload %} <a class="btn btn-default" href='{{ ctx.url_for('org_contest_scans') }}'>Zpracování skenů</a> {% endif %} + {% if not site and can_manage %} {% if state != RoundState.closed and round.seq > 1 %} <a class="btn btn-primary" href='{{ ctx.url_for('org_contest_advance') }}'>Postup z minulého kola</a> {% endif %} - {% if can_manage %} <a class="btn btn-default" href='{{ ctx.url_for('org_import_user') }}'>Importovat účastníky</a> <a class="btn btn-default" href='{{ ctx.url_for('org_import_org') }}'>Importovat organizátory</a> - {% endif %} - {% if can_manage and not site %} <a class="btn btn-default" href='{{ ctx.url_for('org_contest_edit') }}'>Nastavení</a> {% endif %} - {% if g.user.is_admin %} + {% if not site and g.user.is_admin %} <a class="btn btn-default" href="{{ log_url('contest', ctx.ct_id) }}">Historie</a> {% endif %} - {% endif %} </div> +{% endif %} {% if not site %} <h3>Soutěžní místa</h3> @@ -116,11 +120,12 @@ <p><i>Žádní účastníci a žádná soutěžní místa.</i></p> {% endif %} {% endif %} + +{% if can_manage and not site %} <div class="btn-group"> - {% if can_manage and not site %} <a class="btn btn-default" href='{{ ctx.url_for('org_contest_add_user') }}'>Přidat účastníka</a> - {% endif %} </div> +{% endif %} <h3>Úlohy</h3> {% if tasks %}