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
MO-P
Odevzdávací Systém MO
Commits
478b89ae
Project 'mj/mo-submit' was moved to 'mo-p/osmo'. Please update any links and bookmarks that may still have the old path.
Commit
478b89ae
authored
Jan 16, 2021
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
rights: fixup!
parent
1d20c08e
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/rights.py
+7
-4
7 additions, 4 deletions
mo/rights.py
with
7 additions
and
4 deletions
mo/rights.py
+
7
−
4
View file @
478b89ae
...
...
@@ -133,8 +133,9 @@ class Rights:
rights
:
Set
[
Right
]
def
__repr__
(
self
):
rs
=
"
"
.
join
([
r
.
role
.
name
for
r
in
self
.
roles
])
return
f
"
Rights(uid=
{
self
.
user
.
user_id
}
is_admin=
{
self
.
user
.
is_admin
}
roles=<
{
rs
}
>)
"
ros
=
"
"
.
join
([
r
.
role
.
name
for
r
in
self
.
roles
])
ris
=
"
"
.
join
([
r
.
name
for
r
in
self
.
rights
])
return
f
"
Rights(uid=
{
self
.
user
.
user_id
}
is_admin=
{
self
.
user
.
is_admin
}
roles=<
{
ros
}
> rights=<
{
ris
}
>)
"
def
have_right
(
self
,
right
:
Right
):
if
self
.
user
.
is_admin
:
...
...
@@ -166,11 +167,13 @@ class Gatekeeper:
nebo právě zpracovávaný job.
"""
user
:
db
.
User
roles
:
List
[
db
.
UserRole
]
parent_cache
:
Dict
[
int
,
List
[
db
.
Place
]]
rights_cache
:
Dict
[
Tuple
[
Optional
[
int
],
Optional
[
int
],
Optional
[
str
],
Optional
[
int
],
Optional
[
db
.
RoleType
]],
Rights
]
def
__init__
(
self
,
user
:
db
.
User
):
self
.
user
=
user
self
.
roles
=
user
.
roles
assert
user
.
is_org
or
user
.
is_admin
self
.
parent_cache
=
{}
self
.
rights_cache
=
{}
...
...
@@ -212,11 +215,11 @@ class Gatekeeper:
# XXX: This might be faster...
if
place
is
None
:
for
role
in
rights
.
roles
:
for
role
in
self
.
roles
:
try_role
(
role
,
None
)
else
:
for
at
in
self
.
get_parents
(
place
):
for
role
in
rights
.
roles
:
for
role
in
self
.
roles
:
try_role
(
role
,
at
)
return
rights
...
...
...
...
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
sign in
to comment