Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
b31bd86d
Commit
b31bd86d
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Skripty create-{contests,round} umí dělená kola
parent
4e576938
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/create-contests
+33
-13
33 additions, 13 deletions
bin/create-contests
bin/create-round
+17
-0
17 additions, 0 deletions
bin/create-round
with
50 additions
and
13 deletions
bin/create-contests
+
33
−
13
View file @
b31bd86d
...
...
@@ -7,7 +7,7 @@ import mo.util
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
'
,
help
=
'
ID kola
'
)
parser
.
add_argument
(
dest
=
'
round
'
,
type
=
str
,
metavar
=
'
YY-C-S
[p]
'
,
help
=
'
ID kola
'
)
parser
.
add_argument
(
'
-n
'
,
'
--dry-run
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
pouze ukáže, co by bylo provedeno
'
)
args
=
parser
.
parse_args
()
...
...
@@ -22,6 +22,23 @@ round = mo.util.get_round_by_code(round_code)
if
round
is
None
:
die
(
"
Kolo s tímto kódem 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
):
r
=
mc
.
place
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
)
sess
.
add
(
c
)
sess
.
flush
()
mo
.
util
.
log
(
db
.
LogType
.
contest
,
c
.
contest_id
,
{
'
action
'
:
'
created
'
,
})
else
:
regions
=
sess
.
query
(
db
.
Place
).
filter_by
(
level
=
round
.
level
).
all
()
assert
regions
,
"
Neexistují žádná místa dané úrovně
"
...
...
@@ -29,11 +46,14 @@ 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
)
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
()
This diff is collapsed.
Click to expand it.
bin/create-round
+
17
−
0
View file @
b31bd86d
...
...
@@ -4,12 +4,14 @@ import argparse
import
mo.db
as
db
import
mo.util
from
mo.util
import
die
parser
=
argparse
.
ArgumentParser
(
description
=
'
Založí soutěžní kolo
'
)
parser
.
add_argument
(
'
-y
'
,
'
--year
'
,
type
=
int
,
required
=
True
,
help
=
'
ročník
'
)
parser
.
add_argument
(
'
-c
'
,
'
--cat
'
,
type
=
str
,
required
=
True
,
help
=
'
kategorie
'
)
parser
.
add_argument
(
'
-s
'
,
'
--seq
'
,
type
=
int
,
required
=
True
,
help
=
'
pořadí kola
'
)
parser
.
add_argument
(
'
-l
'
,
'
--level
'
,
type
=
int
,
required
=
True
,
help
=
'
úroveň v hierarchii oblastí
'
)
parser
.
add_argument
(
'
-p
'
,
'
--part
'
,
type
=
int
,
default
=
0
,
help
=
'
část v rámci skupiny kol (default: 0)
'
)
parser
.
add_argument
(
'
-n
'
,
'
--name
'
,
type
=
str
,
required
=
True
,
help
=
'
název kola
'
)
args
=
parser
.
parse_args
()
...
...
@@ -17,10 +19,20 @@ args = parser.parse_args()
mo
.
util
.
init_standalone
()
sess
=
db
.
get_session
()
if
args
.
part
>
1
:
master_rnd
=
sess
.
query
(
db
.
Round
).
filter_by
(
year
=
args
.
year
,
category
=
args
.
cat
,
seq
=
args
.
seq
,
part
=
1
).
one_or_none
()
if
master_rnd
is
None
or
master_rnd
.
is_subround
():
die
(
"
Nemohu nalézt hlavní kolo
"
)
if
master_rnd
.
level
!=
args
.
level
:
die
(
"
Hlavní kolo probíhá na odlišné úrovni hierarchie
"
)
else
:
master_rnd
=
None
rnd
=
db
.
Round
(
year
=
args
.
year
,
category
=
args
.
cat
,
seq
=
args
.
seq
,
part
=
args
.
part
,
level
=
args
.
level
,
name
=
args
.
name
,
)
...
...
@@ -28,6 +40,11 @@ rnd = db.Round(
sess
.
add
(
rnd
)
sess
.
flush
()
if
master_rnd
is
not
None
:
rnd
.
master_round_id
=
master_rnd
.
round_id
else
:
rnd
.
master_round_id
=
rnd
.
round_id
mo
.
util
.
log
(
type
=
db
.
LogType
.
round
,
what
=
rnd
.
round_id
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment