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
99abbb98
Commit
99abbb98
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Registrace: Soutěže s více částmi
parent
9529b3e3
No related branches found
No related tags found
1 merge request
!86
Registrace
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/web/org_round.py
+18
-10
18 additions, 10 deletions
mo/web/org_round.py
mo/web/user.py
+5
-2
5 additions, 2 deletions
mo/web/user.py
with
23 additions
and
12 deletions
mo/web/org_round.py
+
18
−
10
View file @
99abbb98
...
...
@@ -152,14 +152,26 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool:
)
app
.
logger
.
info
(
f
"
Soutěž #
{
contest
.
contest_id
}
založena:
{
db
.
row2dict
(
contest
)
}
"
)
# Přidání soutěže do podkol ve skupině
subrounds
=
round
.
master
.
get_group_rounds
()
create_subcontests
(
round
.
master
,
contest
)
sess
.
commit
()
flash
(
f
'
Založena soutěž
{
place
.
name_locative
()
}
'
,
'
success
'
)
return
True
# XXX: Používá se i v registraci účastníků
def
create_subcontests
(
master_round
:
db
.
Round
,
master_contest
:
db
.
Contest
):
if
master_round
.
part
==
0
:
return
sess
=
db
.
get_session
()
subrounds
=
master_round
.
get_group_rounds
()
for
subround
in
subrounds
:
subcontest
=
db
.
Contest
(
round_id
=
subround
.
round_id
,
master_contest_id
=
contest
.
contest_id
,
place_id
=
contest
.
place_id
,
state
=
state
,
master_contest_id
=
master_
contest
.
contest_id
,
place_id
=
master_
contest
.
place_id
,
state
=
master_contest
.
state
,
)
sess
.
add
(
subcontest
)
sess
.
flush
()
...
...
@@ -169,11 +181,7 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool:
what
=
subcontest
.
contest_id
,
details
=
{
'
action
'
:
'
add
'
,
'
contest
'
:
db
.
row2dict
(
subcontest
)},
)
app
.
logger
.
info
(
f
"
Soutěž #
{
subcontest
.
contest_id
}
založena:
{
db
.
row2dict
(
subcontest
)
}
"
)
sess
.
commit
()
flash
(
f
'
Založena soutěž
{
place
.
name_locative
()
}
'
,
'
success
'
)
return
True
app
.
logger
.
info
(
f
"
Podsoutěž #
{
subcontest
.
contest_id
}
založena:
{
db
.
row2dict
(
subcontest
)
}
"
)
@app.route
(
'
/org/contest/r/<int:id>/
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
...
...
This diff is collapsed.
Click to expand it.
mo/web/user.py
+
5
−
2
View file @
99abbb98
...
...
@@ -18,6 +18,7 @@ from mo.util import logger
from
mo.util_format
import
time_and_timedelta
from
mo.web
import
app
import
mo.web.fields
as
mo_fields
import
mo.web.org_round
import
mo.web.util
...
...
@@ -87,7 +88,7 @@ def user_join_round(round_id):
raise
werkzeug
.
exceptions
.
NotFound
()
if
(
round
.
year
!=
mo
.
current_year
or
round
.
part
!=
0
or
round
.
part
>
1
or
round
.
enroll_mode
not
in
[
db
.
RoundEnrollMode
.
register
,
db
.
RoundEnrollMode
.
confirm
]
or
round
.
state
!=
db
.
RoundState
.
running
):
flash
(
'
Do této kategorie se není možné přihlásit.
'
,
'
danger
'
)
...
...
@@ -181,7 +182,7 @@ def join_create_contest(round: db.Round, pant: db.Participant) -> db.Contest:
# XXX: Z rekurzivního dotazu nedostaneme plnohodnotný db.Place, ale jenom named tuple, tak musíme pracovat s ID.
place_id
=
place
.
place_id
assert
round
.
part
=
=
0
# U kol s více částmi bude potřeba založit všechny contesty, ale přihlásit jen do primárního
assert
round
.
part
<
=
1
c
=
(
sess
.
query
(
db
.
Contest
)
.
filter_by
(
round
=
round
,
place_id
=
place_id
)
.
with_for_update
()
...
...
@@ -203,6 +204,8 @@ def join_create_contest(round: db.Round, pant: db.Participant) -> db.Contest:
details
=
{
'
action
'
:
'
created
'
,
'
reason
'
:
'
user-join
'
},
)
mo
.
web
.
org_round
.
create_subcontests
(
round
,
c
)
return
c
...
...
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