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
d525cc70
Commit
d525cc70
authored
5 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Diplomy/UI: Účastníci vidí jen schválené diplomy
parent
c5cd35ef
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/user.py
+13
-5
13 additions, 5 deletions
mo/web/user.py
with
13 additions
and
5 deletions
mo/web/user.py
+
13
−
5
View file @
d525cc70
...
@@ -53,6 +53,8 @@ def user_index():
...
@@ -53,6 +53,8 @@ def user_index():
def
load_pcrs
()
->
List
[
Tuple
[
db
.
Participation
,
db
.
Contest
,
db
.
Round
,
int
]]:
def
load_pcrs
()
->
List
[
Tuple
[
db
.
Participation
,
db
.
Contest
,
db
.
Round
,
int
]]:
cert_subq
=
(
db
.
get_session
()
cert_subq
=
(
db
.
get_session
()
.
query
(
db
.
Certificate
.
user_id
,
db
.
Certificate
.
cert_set_id
,
func
.
count
(
db
.
Certificate
.
type
).
label
(
'
count
'
))
.
query
(
db
.
Certificate
.
user_id
,
db
.
Certificate
.
cert_set_id
,
func
.
count
(
db
.
Certificate
.
type
).
label
(
'
count
'
))
.
join
(
db
.
Certificate
.
cert_file
)
.
filter
(
db
.
CertFile
.
approved
)
.
group_by
(
db
.
Certificate
.
user_id
,
db
.
Certificate
.
cert_set_id
)
.
group_by
(
db
.
Certificate
.
user_id
,
db
.
Certificate
.
cert_set_id
)
.
subquery
())
.
subquery
())
return
(
db
.
get_session
().
query
(
db
.
Participation
,
db
.
Contest
,
db
.
Round
,
cert_subq
.
c
.
count
)
return
(
db
.
get_session
().
query
(
db
.
Participation
,
db
.
Contest
,
db
.
Round
,
cert_subq
.
c
.
count
)
...
@@ -341,7 +343,10 @@ def user_contest(id: int):
...
@@ -341,7 +343,10 @@ def user_contest(id: int):
if
contest
.
state
==
db
.
RoundState
.
closed
:
if
contest
.
state
==
db
.
RoundState
.
closed
:
certs
=
(
sess
.
query
(
db
.
Certificate
)
certs
=
(
sess
.
query
(
db
.
Certificate
)
.
filter_by
(
cert_set_id
=
id
,
user
=
g
.
user
)
.
join
(
db
.
Certificate
.
cert_file
)
.
filter
(
db
.
Certificate
.
cert_set_id
==
id
,
db
.
Certificate
.
user
==
g
.
user
,
db
.
CertFile
.
approved
)
.
limit
(
1
)
.
limit
(
1
)
.
all
())
.
all
())
else
:
else
:
...
@@ -642,7 +647,7 @@ def user_contest_score_pdf(id: int):
...
@@ -642,7 +647,7 @@ def user_contest_score_pdf(id: int):
# Využívá se i z org_certs
# Využívá se i z org_certs
def
send_certificate
(
ct_id
:
int
,
cert_type
:
str
,
user_filename
:
str
,
user_id
:
Optional
[
int
]
=
None
):
def
send_certificate
(
ct_id
:
int
,
cert_type
:
str
,
user_filename
:
str
,
user_id
:
Optional
[
int
]
=
None
,
approved_only
:
bool
=
False
):
try
:
try
:
typ
=
db
.
CertType
.
coerce
(
cert_type
)
typ
=
db
.
CertType
.
coerce
(
cert_type
)
except
ValueError
:
except
ValueError
:
...
@@ -653,7 +658,7 @@ def send_certificate(ct_id: int, cert_type: str, user_filename: str, user_id: Op
...
@@ -653,7 +658,7 @@ def send_certificate(ct_id: int, cert_type: str, user_filename: str, user_id: Op
sess
=
db
.
get_session
()
sess
=
db
.
get_session
()
cfile
=
sess
.
query
(
db
.
CertFile
).
get
((
ct_id
,
typ
))
cfile
=
sess
.
query
(
db
.
CertFile
).
get
((
ct_id
,
typ
))
if
cfile
is
None
:
if
cfile
is
None
or
(
approved_only
and
not
cfile
.
published
)
:
raise
werkzeug
.
exceptions
.
NotFound
()
raise
werkzeug
.
exceptions
.
NotFound
()
file
=
os
.
path
.
join
(
mo
.
util
.
data_dir
(
'
certs
'
),
cfile
.
pdf_file
)
file
=
os
.
path
.
join
(
mo
.
util
.
data_dir
(
'
certs
'
),
cfile
.
pdf_file
)
...
@@ -698,7 +703,10 @@ def user_contest_certificates(id: int):
...
@@ -698,7 +703,10 @@ def user_contest_certificates(id: int):
sess
=
db
.
get_session
()
sess
=
db
.
get_session
()
cset
=
sess
.
query
(
db
.
CertSet
).
filter_by
(
contest_id
=
id
).
one_or_none
()
cset
=
sess
.
query
(
db
.
CertSet
).
filter_by
(
contest_id
=
id
).
one_or_none
()
certs
=
(
sess
.
query
(
db
.
Certificate
)
certs
=
(
sess
.
query
(
db
.
Certificate
)
.
filter_by
(
cert_set_id
=
id
,
user
=
g
.
user
)
.
join
(
db
.
Certificate
.
cert_file
)
.
filter
(
db
.
Certificate
.
cert_set_id
==
id
,
db
.
Certificate
.
user
==
g
.
user
,
db
.
CertFile
.
approved
)
.
all
())
.
all
())
return
render_template
(
return
render_template
(
...
@@ -713,7 +721,7 @@ def user_contest_certificates(id: int):
...
@@ -713,7 +721,7 @@ def user_contest_certificates(id: int):
def
user_cert_file
(
ct_id
:
int
,
cert_type
:
str
,
filename
:
str
):
def
user_cert_file
(
ct_id
:
int
,
cert_type
:
str
,
filename
:
str
):
_
=
get_contest
(
ct_id
)
_
=
get_contest
(
ct_id
)
return
send_certificate
(
ct_id
,
cert_type
,
filename
,
g
.
user_id
)
return
send_certificate
(
ct_id
,
cert_type
,
filename
,
g
.
user_id
,
approved_only
=
True
)
@app.route
(
'
/user/history/
'
)
@app.route
(
'
/user/history/
'
)
...
...
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