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

Při zakládání contestů kopírujeme round.state

parent b83d8c0b
No related branches found
No related tags found
1 merge request!49Stavy soutěže
......@@ -22,6 +22,11 @@ round = mo.util.get_round_by_code(round_code)
if round is None:
die("Kolo s tímto kódem neexistuje!")
if round.state != db.RoundState.delegate:
state = round.state
else:
state = db.RoundState.preparing
if round.is_subround():
# Pokud je to podkolo, kopírujeme soutěže z hlavního kola
for mc in sess.query(db.Contest).filter_by(round=round.master):
......@@ -29,7 +34,7 @@ if round.is_subround():
print(f"Zakládám {round.round_code()} pro místo {r.name} (podsoutěž)")
if not args.dry_run:
c = db.Contest(round=round, place=r, master=mc)
c = db.Contest(round=round, place=r, master=mc, state=state)
sess.add(c)
sess.flush()
......@@ -45,7 +50,7 @@ else:
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)
c = db.Contest(round=round, place=r, state=state)
sess.add(c)
sess.flush()
......
......@@ -111,8 +111,14 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool:
flash(f'Pro {place.type_name()} {place.name} už toto kolo existuje', 'danger')
return False
# Počáteční stav soutěže
if round.state != db.RoundState.delegate:
state = round.state
else:
state = db.RoundState.preparing
# Soutěž vytvoříme vždy v hlavním kole
contest = db.Contest(round=round.master, place=place)
contest = db.Contest(round=round.master, place=place, state=state)
rr = g.gatekeeper.rights_for_contest(contest)
if not rr.have_right(Right.add_contest):
flash('Vaše role nedovoluje vytvořit soutěž v oblasti {place.type_name()} {place.name}', 'danger')
......@@ -138,6 +144,7 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool:
round_id=subround.round_id,
master_contest_id=contest.contest_id,
place_id=contest.place_id,
state=state,
)
sess.add(subcontest)
sess.flush()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment