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
13f5c44f
Commit
13f5c44f
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Výpis a export všech účastníků daného kola
Closes
#15
.
parent
e036a18a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/org_contest.py
+55
-28
55 additions, 28 deletions
mo/web/org_contest.py
with
55 additions
and
28 deletions
mo/web/org_contest.py
+
55
−
28
View file @
13f5c44f
...
@@ -5,7 +5,7 @@ import locale
...
@@ -5,7 +5,7 @@ import locale
import
os
import
os
import
secrets
import
secrets
from
sqlalchemy.orm
import
joinedload
from
sqlalchemy.orm
import
joinedload
from
typing
import
List
,
Tuple
,
Optional
from
typing
import
List
,
Tuple
,
Optional
,
Sequence
import
werkzeug.exceptions
import
werkzeug.exceptions
import
wtforms
import
wtforms
...
@@ -75,7 +75,19 @@ def org_round(id: int):
...
@@ -75,7 +75,19 @@ def org_round(id: int):
@app.route
(
'
/org/contest/r/<int:id>/list
'
)
@app.route
(
'
/org/contest/r/<int:id>/list
'
)
def
org_round_list
(
id
:
int
):
def
org_round_list
(
id
:
int
):
return
render_template
(
'
not_implemented.html
'
)
round
,
rr
=
get_round_rr
(
id
,
mo
.
rights
.
Right
.
manage_contest
)
format
=
request
.
args
.
get
(
'
format
'
,
""
)
table
=
make_contestant_table
(
round
,
None
)
if
format
==
""
:
return
render_template
(
'
org_round_list.html
'
,
round
=
round
,
table
=
table
,
)
else
:
return
table
.
send_as
(
format
)
@app.route
(
'
/org/contest/r/<int:id>/import
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
@app.route
(
'
/org/contest/r/<int:id>/import
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
...
@@ -193,6 +205,23 @@ def org_contest_import_template():
...
@@ -193,6 +205,23 @@ def org_contest_import_template():
return
resp
return
resp
@app.route
(
'
/org/contest/c/<int:id>/ucastnici
'
)
def
org_contest_list
(
id
:
int
):
contest
,
rr
=
get_contest_rr
(
id
,
mo
.
rights
.
Right
.
manage_contest
)
format
=
request
.
args
.
get
(
'
format
'
,
""
)
table
=
make_contestant_table
(
contest
.
round
,
contest
)
if
format
==
""
:
return
render_template
(
'
org_contest_list.html
'
,
contest
=
contest
,
table
=
table
,
)
else
:
return
table
.
send_as
(
format
)
contest_list_columns
=
(
contest_list_columns
=
(
Column
(
key
=
'
first_name
'
,
name
=
'
krestni
'
,
title
=
'
Křestní jméno
'
),
Column
(
key
=
'
first_name
'
,
name
=
'
krestni
'
,
title
=
'
Křestní jméno
'
),
Column
(
key
=
'
last_name
'
,
name
=
'
prijmeni
'
,
title
=
'
Příjmení
'
),
Column
(
key
=
'
last_name
'
,
name
=
'
prijmeni
'
,
title
=
'
Příjmení
'
),
...
@@ -206,24 +235,26 @@ contest_list_columns = (
...
@@ -206,24 +235,26 @@ contest_list_columns = (
)
)
@app.route
(
'
/org/contest/c/<int:id>/ucastnici
'
)
def
make_contestant_table
(
round
:
db
.
Round
,
contest
:
Optional
[
db
.
Contest
])
->
Table
:
def
org_contest_list
(
id
:
int
):
query
=
(
db
.
get_session
()
contest
,
rr
=
get_contest_rr
(
id
,
mo
.
rights
.
Right
.
manage_contest
)
.
query
(
db
.
Participation
,
db
.
Participant
,
db
.
Contest
)
format
=
request
.
args
.
get
(
'
format
'
,
""
)
ctants
=
(
db
.
get_session
()
.
query
(
db
.
Participation
,
db
.
Participant
)
.
select_from
(
db
.
Participation
)
.
select_from
(
db
.
Participation
)
.
join
(
db
.
Participant
,
db
.
Participant
.
user_id
==
db
.
Participation
.
user_id
)
.
join
(
db
.
Participant
,
db
.
Participant
.
user_id
==
db
.
Participation
.
user_id
)
.
options
(
joinedload
(
db
.
Participation
.
user
),
.
filter
(
db
.
Participant
.
year
==
round
.
year
))
if
contest
:
query
=
query
.
join
(
db
.
Contest
,
db
.
Contest
.
contest_id
==
contest
.
contest_id
)
else
:
query
=
query
.
filter
(
db
.
Contest
.
round
==
round
)
query
=
query
.
options
(
joinedload
(
db
.
Contest
.
place
))
query
=
query
.
filter
(
db
.
Participation
.
contest_id
==
db
.
Contest
.
contest_id
)
query
=
query
.
options
(
joinedload
(
db
.
Participation
.
user
),
joinedload
(
db
.
Participation
.
place
),
joinedload
(
db
.
Participation
.
place
),
joinedload
(
db
.
Participant
.
school_place
))
joinedload
(
db
.
Participant
.
school_place
))
.
filter
(
db
.
Participation
.
contest
==
contest
)
.
filter
(
db
.
Participant
.
year
==
contest
.
round
.
year
)
ctants
=
query
.
all
()
.
all
())
rows
:
List
[
dict
]
=
[]
rows
:
List
[
dict
]
=
[]
for
pion
,
pant
in
ctants
:
for
pion
,
pant
,
ct
in
ctants
:
rows
.
append
({
rows
.
append
({
'
first_name
'
:
pion
.
user
.
first_name
,
'
first_name
'
:
pion
.
user
.
first_name
,
'
last_name
'
:
pion
.
user
.
last_name
,
'
last_name
'
:
pion
.
user
.
last_name
,
...
@@ -232,23 +263,19 @@ def org_contest_list(id: int):
...
@@ -232,23 +263,19 @@ def org_contest_list(id: int):
'
school_code
'
:
cell_place_link
(
pant
.
school_place
,
pant
.
school_place
.
get_code
()),
'
school_code
'
:
cell_place_link
(
pant
.
school_place
,
pant
.
school_place
.
get_code
()),
'
grade
'
:
pant
.
grade
,
'
grade
'
:
pant
.
grade
,
'
born_year
'
:
pant
.
birth_year
,
'
born_year
'
:
pant
.
birth_year
,
'
region_code
'
:
ct
.
place
.
get_code
(),
'
place_code
'
:
pion
.
place
.
get_code
(),
'
place_code
'
:
pion
.
place
.
get_code
(),
'
status
'
:
pion
.
state
.
name
,
'
status
'
:
pion
.
state
.
name
,
})
})
rows
.
sort
(
key
=
lambda
r
:
(
locale
.
strxfrm
(
r
[
'
last_name
'
]),
locale
.
strxfrm
(
r
[
'
first_name
'
])))
rows
.
sort
(
key
=
lambda
r
:
(
locale
.
strxfrm
(
r
[
'
last_name
'
]),
locale
.
strxfrm
(
r
[
'
first_name
'
])))
table
=
Table
(
cols
:
Sequence
[
Column
]
=
contest_list_columns
columns
=
contest_list_columns
,
if
not
contest
:
cols
=
list
(
cols
)
+
[
Column
(
key
=
'
region_code
'
,
name
=
'
kod_oblasti
'
,
title
=
'
Oblast
'
)]
return
Table
(
columns
=
cols
,
rows
=
rows
,
rows
=
rows
,
filename
=
'
ucastnici
'
,
filename
=
'
ucastnici
'
,
)
)
if
format
==
""
:
return
render_template
(
'
org_contest_list.html
'
,
contest
=
contest
,
table
=
table
,
)
else
:
return
table
.
send_as
(
format
)
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