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
41c48802
Commit
41c48802
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Částečné omezení práv ke kolům.
Viz diskuse u
#155
.
parent
ea563425
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mo/rights.py
+6
-2
6 additions, 2 deletions
mo/rights.py
mo/web/org_round.py
+11
-11
11 additions, 11 deletions
mo/web/org_round.py
mo/web/org_score.py
+1
-1
1 addition, 1 deletion
mo/web/org_score.py
with
18 additions
and
14 deletions
mo/rights.py
+
6
−
2
View file @
41c48802
...
...
@@ -280,8 +280,12 @@ class Gatekeeper:
"""
Posbírá role a práva, ale ignoruje omezení rolí na místa a soutěže. Hodí se pro práva k editaci uživatelů apod.
"""
return
self
.
rights_for
()
def
rights_for_round
(
self
,
round
:
db
.
Round
):
return
self
.
rights_for
(
place
=
None
,
year
=
round
.
year
,
cat
=
round
.
category
,
seq
=
round
.
seq
)
def
rights_for_round
(
self
,
round
:
db
.
Round
,
any_place
:
bool
):
if
any_place
:
place
=
None
else
:
place
=
db
.
get_root_place
()
return
self
.
rights_for
(
place
=
place
,
year
=
round
.
year
,
cat
=
round
.
category
,
seq
=
round
.
seq
)
def
rights_for_contest
(
self
,
contest
:
db
.
Contest
):
return
self
.
rights_for
(
place
=
contest
.
place
,
year
=
contest
.
round
.
year
,
cat
=
contest
.
round
.
category
,
seq
=
contest
.
round
.
seq
)
...
...
This diff is collapsed.
Click to expand it.
mo/web/org_round.py
+
11
−
11
View file @
41c48802
...
...
@@ -26,10 +26,10 @@ def get_round(id: int) -> db.Round:
return
round
def
get_round_rr
(
id
:
int
,
right_needed
:
Optional
[
Right
])
->
Tuple
[
db
.
Round
,
Rights
]:
def
get_round_rr
(
id
:
int
,
right_needed
:
Optional
[
Right
]
,
any_place
:
bool
)
->
Tuple
[
db
.
Round
,
Rights
]:
round
=
get_round
(
id
)
rr
=
g
.
gatekeeper
.
rights_for_round
(
round
)
rr
=
g
.
gatekeeper
.
rights_for_round
(
round
,
any_place
)
if
not
(
right_needed
is
None
or
rr
.
have_right
(
right_needed
)):
raise
werkzeug
.
exceptions
.
Forbidden
()
...
...
@@ -129,7 +129,7 @@ def add_contest(round: db.Round, form: AddContestForm) -> bool:
@app.route
(
'
/org/contest/r/<int:id>/
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round
(
id
:
int
):
sess
=
db
.
get_session
()
round
,
rr
=
get_round_rr
(
id
,
None
)
round
,
rr
=
get_round_rr
(
id
,
None
,
True
)
can_manage_round
=
rr
.
have_right
(
Right
.
manage_round
)
can_manage_contestants
=
rr
.
have_right
(
Right
.
manage_contest
)
...
...
@@ -199,7 +199,7 @@ class TaskEditForm(FlaskForm):
@app.route
(
'
/org/contest/r/<int:id>/task/new
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_task_new
(
id
:
int
):
sess
=
db
.
get_session
()
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
)
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
,
True
)
form
=
TaskEditForm
()
if
form
.
validate_on_submit
():
...
...
@@ -231,7 +231,7 @@ def org_round_task_new(id: int):
@app.route
(
'
/org/contest/r/<int:id>/task/<int:task_id>/edit
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_task_edit
(
id
:
int
,
task_id
:
int
):
sess
=
db
.
get_session
()
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
)
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
,
True
)
task
=
sess
.
query
(
db
.
Task
).
get
(
task_id
)
# FIXME: Check contest!
...
...
@@ -271,7 +271,7 @@ def org_round_task_edit(id: int, task_id: int):
@app.route
(
'
/org/contest/r/<int:round_id>/task/<int:task_id>/download
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_task_download
(
round_id
:
int
,
task_id
:
int
):
sess
=
db
.
get_session
()
round
,
rr
=
get_round_rr
(
round_id
,
Right
.
view_submits
)
round
,
rr
=
get_round_rr
(
round_id
,
Right
.
view_submits
,
False
)
task
=
sess
.
query
(
db
.
Task
).
get
(
task_id
)
if
not
task
or
task
.
round_id
!=
round_id
:
...
...
@@ -283,7 +283,7 @@ def org_round_task_download(round_id: int, task_id: int):
@app.route
(
'
/org/contest/r/<int:round_id>/task/<int:task_id>/upload
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_task_upload
(
round_id
:
int
,
task_id
:
int
):
sess
=
db
.
get_session
()
round
,
rr
=
get_round_rr
(
round_id
,
Right
.
view_submits
)
round
,
rr
=
get_round_rr
(
round_id
,
Right
.
view_submits
,
False
)
task
=
sess
.
query
(
db
.
Task
).
get
(
task_id
)
if
not
task
or
task
.
round_id
!=
round_id
:
...
...
@@ -296,7 +296,7 @@ def org_round_task_upload(round_id: int, task_id: int):
@app.route
(
'
/org/contest/r/<int:id>/list
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_list
(
id
:
int
):
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_contest
)
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_contest
,
True
)
format
=
request
.
args
.
get
(
'
format
'
,
""
)
filter
=
ParticipantsFilterForm
(
request
.
args
)
...
...
@@ -332,7 +332,7 @@ def org_round_list(id: int):
@app.route
(
'
/org/contest/r/<int:id>/import
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_import
(
id
:
int
):
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_contest
)
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_contest
,
True
)
return
generic_import
(
round
,
None
)
...
...
@@ -363,7 +363,7 @@ class RoundEditForm(FlaskForm):
@app.route
(
'
/org/contest/r/<int:id>/edit
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
def
org_round_edit
(
id
:
int
):
sess
=
db
.
get_session
()
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
)
round
,
rr
=
get_round_rr
(
id
,
Right
.
manage_round
,
True
)
form
=
RoundEditForm
(
obj
=
round
)
if
form
.
validate_on_submit
():
...
...
@@ -394,7 +394,7 @@ def org_round_edit(id: int):
@app.route
(
'
/org/contest/r/<int:id>/task-statement/zadani.pdf
'
)
def
org_task_statement
(
id
:
int
):
round
,
rr
=
get_round_rr
(
id
,
None
)
round
,
rr
=
get_round_rr
(
id
,
None
,
True
)
if
not
rr
.
can_view_statement
(
round
):
app
.
logger
.
warn
(
f
'
Organizátor #
{
g
.
user
.
user_id
}
chce zadání, na které nemá právo
'
)
...
...
This diff is collapsed.
Click to expand it.
mo/web/org_score.py
+
1
−
1
View file @
41c48802
...
...
@@ -97,7 +97,7 @@ def org_score(round_id: Optional[int] = None, contest_id: Optional[int] = None):
round
=
sess
.
query
(
db
.
Round
).
get
(
round_id
)
if
not
round
:
raise
werkzeug
.
exceptions
.
NotFound
()
rr
=
g
.
gatekeeper
.
rights_for_round
(
round
)
rr
=
g
.
gatekeeper
.
rights_for_round
(
round
,
True
)
contest_subq
=
sess
.
query
(
db
.
Contest
.
contest_id
).
filter_by
(
round
=
round
)
user_id_subq
=
user_id_subq
.
filter
(
db
.
Participation
.
contest_id
.
in_
(
contest_subq
))
else
:
...
...
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