Skip to content
Snippets Groups Projects

Testovací prostředí

Merged Martin Mareš requested to merge mj/testing into devel
13 files
+ 524
30
Compare changes
  • Side-by-side
  • Inline

Files

+ 16
3
@@ -8,6 +8,7 @@ from mo.util import die, init_standalone
@@ -8,6 +8,7 @@ from mo.util import die, init_standalone
parser = argparse.ArgumentParser(description='Založí soutěže pro dané kolo')
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(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')
parser.add_argument('-n', '--dry-run', default=False, action='store_true', help='pouze ukáže, co by bylo provedeno')
args = parser.parse_args()
args = parser.parse_args()
@@ -27,9 +28,18 @@ if round.state != db.RoundState.delegate:
@@ -27,9 +28,18 @@ if round.state != db.RoundState.delegate:
else:
else:
state = db.RoundState.preparing
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():
if round.is_subround():
# Pokud je to podkolo, kopírujeme soutěže z hlavního kola
# 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
r = mc.place
print(f"{round.round_code()} pro místo {r.name}: zakládám (podsoutěž)")
print(f"{round.round_code()} pro místo {r.name}: zakládám (podsoutěž)")
@@ -44,8 +54,11 @@ if round.is_subround():
@@ -44,8 +54,11 @@ if round.is_subround():
})
})
else:
else:
regions = sess.query(db.Place).filter_by(level=round.level).all()
if region is None:
assert regions, "Neexistují žádná místa dané úrovně"
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:
for r in regions:
if sess.query(db.Contest).filter_by(round=round, place=r).first():
if sess.query(db.Contest).filter_by(round=round, place=r).first():
Loading