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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Compare revisions
efd69628b4bf841e4c202c3cf30207b10981e4fc to f750836a9438a290891591a9b2c2a048a950450c
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
mj/mo-submit
Select target project
No results found
f750836a9438a290891591a9b2c2a048a950450c
Select Git revision
Branches
devel
fo
fo-base
honza/add-contestant
honza/kolo-vs-soutez
honza/mr6
honza/mr7
honza/mra
honza/mrd
honza/mrf
honza/submit-images
jh-stress-test-wip
jirka/typing
jk/issue-196
jk/issue-96
master
mj/submit-images
shorten-schools
18 results
Swap
Target
mj/mo-submit
Select target project
mj/mo-submit
1 result
efd69628b4bf841e4c202c3cf30207b10981e4fc
Select Git revision
Branches
devel
fo
fo-base
honza/add-contestant
honza/kolo-vs-soutez
honza/mr6
honza/mr7
honza/mra
honza/mrd
honza/mrf
honza/submit-images
jh-stress-test-wip
jirka/typing
jk/issue-196
jk/issue-96
master
mj/submit-images
shorten-schools
18 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
Opravy vyhodnocování práv k řešením
· d55b49af
Martin Mareš
authored
4 years ago
d55b49af
Endpointy pro zobrazování odevzdaných řešení.
· e6dca6a3
Martin Mareš
authored
4 years ago
e6dca6a3
Další endpointy pro řešení
· f750836a
Martin Mareš
authored
4 years ago
f750836a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/web/org_contest.py
+55
-27
55 additions, 27 deletions
mo/web/org_contest.py
with
55 additions
and
27 deletions
mo/web/org_contest.py
View file @
f750836a
...
...
@@ -451,13 +451,14 @@ class SolutionContext:
contest
:
db
.
Contest
round
:
db
.
Round
pion
:
db
.
Participation
solution
:
db
.
Solution
task
:
db
.
Task
solution
:
Optional
[
db
.
Solution
]
allow_view
:
bool
allow_upload_solutions
:
bool
allow_upload_feedback
:
bool
def
get_solution_context
(
contest_id
,
user_id
,
task_id
)
->
SolutionContext
:
def
get_solution_context
(
contest_id
:
int
,
site_id
:
Optional
[
int
]
,
user_id
:
int
,
task_id
:
int
)
->
SolutionContext
:
sess
=
db
.
get_session
()
# Nejprve zjistíme, zda existuje soutěž
...
...
@@ -472,37 +473,36 @@ def get_solution_context(contest_id, user_id, task_id) -> SolutionContext:
if
not
pion
:
raise
werkzeug
.
exceptions
.
NotFound
()
# Najdeme jeho řešení úlohy
sol
=
(
sess
.
query
(
db
.
Solution
)
.
filter_by
(
user_id
=
user_id
,
task_id
=
task_id
)
.
options
(
joinedload
(
db
.
Solution
.
task
))
.
one_or_none
())
if
not
sol
:
# A zda soutěží na zadaném soutěžním místě, je-li určeno
if
site_id
is
not
None
and
site_id
!=
pion
.
site_id
:
raise
werkzeug
.
exceptions
.
NotFound
()
# Zkontrolujeme, že úloha je součástí soutěže
if
sol
.
round
!=
round
:
# Najdeme úlohu a ověříme, že je součástí soutěže
task
=
sess
.
query
(
db
.
Task
).
get
(
task_id
)
if
not
task
or
task
.
round_id
!=
round
:
raise
werkzeug
.
exceptions
.
NotFound
()
#
Má uživatel práva skrz contest?
rr
=
Rights
(
g
.
user
)
rr
.
get_for_contest
(
contest
)
all_rights
=
rr
.
current_rights
#
Najdeme řešení úlohy (nemusí existovat)
sol
=
(
sess
.
query
(
db
.
Solution
)
.
filter_by
(
user_id
=
user_id
,
task_id
=
task_id
)
.
one_or_none
())
# Má práva skrz soutěžní místo?
if
pion
.
place
!=
contest
.
place
:
rr
.
get_for_contest_site
(
contest
,
pion
.
place
)
all_rights
=
all_rights
|
rr
.
current_rights
# Pokud je uvedeno soutěžní místo, hledáme práva k němu, jinak k soutěži
if
site_id
is
not
None
:
site
=
pion
.
place
else
:
site
=
contest
.
place
rr
=
Rights
(
g
.
user
)
rr
.
get_for_contest_site
(
contest
,
site
)
# Kdo má právo na jaké operace
allow_upload_solutions
=
(
Right
.
manage_contest
in
all_rights
or
(
Right
.
upload_solutions
in
all_rights
and
round
.
state
==
db
.
RoundState
.
running
))
allow_upload_feedback
=
(
Right
.
manage_contest
in
all_rights
or
(
Right
.
upload_feedback
in
all_rights
and
round
.
state
==
db
.
RoundState
.
grading
))
allow_view
=
(
Right
.
manage_contest
in
all_rights
or
(
Right
.
upload_solutions
in
all_rights
and
round
.
state
!=
db
.
RoundState
.
preparing
)
or
(
Right
.
upload_feedback
in
all_rights
and
round
.
state
in
(
db
.
RoundState
.
preparing
,
db
.
RoundState
.
running
,
db
.
RoundState
.
closed
)))
allow_upload_solutions
=
(
rr
.
have_right
(
Right
.
manage_contest
)
or
(
rr
.
have_right
(
Right
.
upload_solutions
)
and
round
.
state
==
db
.
RoundState
.
running
))
allow_upload_feedback
=
(
rr
.
have_right
(
Right
.
manage_contest
)
or
(
rr
.
have_right
(
Right
.
upload_feedback
)
and
round
.
state
==
db
.
RoundState
.
grading
))
allow_view
=
(
rr
.
have_right
(
Right
.
manage_contest
)
or
(
rr
.
have_right
(
Right
.
upload_solutions
)
and
round
.
state
in
(
db
.
RoundState
.
running
,
db
.
RoundState
.
grading
,
db
.
RoundState
.
closed
))
or
(
rr
.
have_right
(
Right
.
upload_feedback
)
and
round
.
state
in
(
db
.
RoundState
.
grading
,
db
.
RoundState
.
closed
)))
if
not
allow_view
:
raise
werkzeug
.
exceptions
.
Forbidden
()
...
...
@@ -510,6 +510,7 @@ def get_solution_context(contest_id, user_id, task_id) -> SolutionContext:
contest
=
contest
,
round
=
round
,
pion
=
pion
,
task
=
task
,
solution
=
sol
,
allow_view
=
allow_view
,
allow_upload_solutions
=
allow_upload_solutions
,
...
...
@@ -519,7 +520,34 @@ def get_solution_context(contest_id, user_id, task_id) -> SolutionContext:
@app.route
(
'
/org/contest/c/<int:contest_id>/submit/<int:user_id>/<int:task_id>/
'
)
def
org_submit_list
(
contest_id
,
user_id
,
task_id
):
sc
=
get_solution_context
(
contest_id
,
user_id
,
task_id
)
sc
=
get_solution_context
(
contest_id
,
None
,
user_id
,
task_id
)
# FIXME
return
render_template
(
'
not_implemented.html
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/site/<int:site_id>/submit/<int:user_id>/<int:task_id>/
'
)
def
org_submit_site_list
(
contest_id
,
site_id
,
user_id
,
task_id
):
sc
=
get_solution_context
(
contest_id
,
site_id
,
user_id
,
task_id
)
# FIXME
return
render_template
(
'
not_implemented.html
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/paper/<int:paper_id>/
'
)
def
org_submit_paper
(
contest_id
,
paper_id
):
# sc = get_solution_context(contest_id, None, user_id, task_id)
# FIXME
return
render_template
(
'
not_implemented.html
'
)
@app.route
(
'
/org/contest/c/<int:contest_id>/site/<int:site_id>/paper/<int:paper_id>/
'
)
def
org_submit_site_paper
(
contest_id
,
paper_id
):
# sc = get_solution_context(contest_id, None, user_id, task_id)
# FIXME
...
...
This diff is collapsed.
Click to expand it.