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
11e458d3
Commit
11e458d3
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Přidávání rolí kontroluje přípustnost kombinace role + level
Closes
#242
.
parent
a2cf4e1e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/db.py
+12
-0
12 additions, 0 deletions
mo/db.py
mo/web/org_users.py
+4
-0
4 additions, 0 deletions
mo/web/org_users.py
with
16 additions
and
0 deletions
mo/db.py
+
12
−
0
View file @
11e458d3
...
...
@@ -549,6 +549,18 @@ class UserRole(Base):
and
(
self
.
category
is
None
or
cat
is
None
or
self
.
category
==
cat
or
(
self
.
category
==
'
Z
'
and
cat
.
startswith
(
'
Z
'
)))
and
(
self
.
seq
is
None
or
seq
is
None
or
self
.
seq
==
seq
))
def
is_legal
(
self
)
->
bool
:
# Některé role mají omezení na úroveň hierarchie.
level
=
self
.
place
.
level
if
self
.
place
else
-
1
rt
=
self
.
role
if
not
(
rt
==
RoleType
.
garant
and
level
<=
0
or
rt
==
RoleType
.
garant_kraj
and
level
==
1
or
rt
==
RoleType
.
garant_okres
and
level
==
2
or
rt
==
RoleType
.
garant_skola
and
level
>=
3
):
return
False
return
True
class
PaperType
(
MOEnum
):
solution
=
auto
()
...
...
This diff is collapsed.
Click to expand it.
mo/web/org_users.py
+
4
−
0
View file @
11e458d3
...
...
@@ -289,6 +289,10 @@ def org_org(id: int):
ok
=
True
if
not
new_role
.
is_legal
():
role_errors
.
append
(
'
Tato kombinace role a místa není povolena
'
)
ok
=
False
elif
not
g
.
gatekeeper
.
can_set_role
(
new_role
):
role_errors
.
append
(
f
'
Roli
"
{
new_role
}
"
nelze přidělit, není podmnožinou žádné vaší role
'
)
ok
=
False
...
...
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