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

create-contests: Zakládání soutěže v konkrétním místě

parent 4f3df053
Branches
No related tags found
1 merge request!121Testovací prostředí
This commit is part of merge request !121. Comments created here will be created in the context of that merge request.
......@@ -8,6 +8,7 @@ from mo.util import die, init_standalone
parser = argparse.ArgumentParser(description='Založí soutěže pro dané kolo')
parser.add_argument(dest='round', type=str, metavar='YY-C-S[p]', help='kód kola')
parser.add_argument('-r', '--region', type=str, metavar='CODE', help='soutěžní oblast (default: založit všechny)')
parser.add_argument('-n', '--dry-run', default=False, action='store_true', help='pouze ukáže, co by bylo provedeno')
args = parser.parse_args()
......@@ -27,9 +28,18 @@ if round.state != db.RoundState.delegate:
else:
state = db.RoundState.preparing
region = None
if args.region is not None:
region = db.get_place_by_code(args.region)
if region is None:
die("Tato oblast neexistuje")
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):
q = sess.query(db.Contest).filter_by(round=round.master)
if region is not None:
q = q.filter_by(place=region.place_id)
for mc in q.all():
r = mc.place
print(f"{round.round_code()} pro místo {r.name}: zakládám (podsoutěž)")
......@@ -44,8 +54,11 @@ if round.is_subround():
})
else:
if region is None:
regions = sess.query(db.Place).filter_by(level=round.level).all()
assert regions, "Neexistují žádná místa dané úrovně"
else:
regions = [region]
for r in regions:
if sess.query(db.Contest).filter_by(round=round, place=r).first():
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment