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
82f53ef0
Commit
82f53ef0
authored
3 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
mo.rights: Kešování root_place
parent
a1f157b9
No related branches found
No related tags found
1 merge request
!97
Import orgů
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/db.py
+2
-1
2 additions, 1 deletion
mo/db.py
mo/rights.py
+8
-1
8 additions, 1 deletion
mo/rights.py
with
10 additions
and
2 deletions
mo/db.py
+
2
−
1
View file @
82f53ef0
...
@@ -136,7 +136,8 @@ class Place(Base):
...
@@ -136,7 +136,8 @@ class Place(Base):
return
place_levels
[
self
.
level
].
in_name
()
+
"
"
+
name
return
place_levels
[
self
.
level
].
in_name
()
+
"
"
+
name
def
get_root_place
():
def
get_root_place
()
->
Place
:
"""
Obvykle voláme mo.rights.Gatekeeper.get_root_place(), kterékešuje.
"""
return
get_session
().
query
(
Place
).
filter_by
(
parent
=
None
).
one
()
return
get_session
().
query
(
Place
).
filter_by
(
parent
=
None
).
one
()
...
...
This diff is collapsed.
Click to expand it.
mo/rights.py
+
8
−
1
View file @
82f53ef0
...
@@ -358,6 +358,7 @@ class Gatekeeper:
...
@@ -358,6 +358,7 @@ class Gatekeeper:
roles
:
List
[
db
.
UserRole
]
roles
:
List
[
db
.
UserRole
]
parent_cache
:
Dict
[
int
,
List
[
db
.
Place
]]
parent_cache
:
Dict
[
int
,
List
[
db
.
Place
]]
rights_cache
:
Dict
[
Tuple
[
Optional
[
int
],
Optional
[
int
],
Optional
[
str
],
Optional
[
int
],
Optional
[
db
.
RoleType
]],
Rights
]
rights_cache
:
Dict
[
Tuple
[
Optional
[
int
],
Optional
[
int
],
Optional
[
str
],
Optional
[
int
],
Optional
[
db
.
RoleType
]],
Rights
]
root_place
:
Optional
[
db
.
Place
]
def
__init__
(
self
,
user
:
db
.
User
):
def
__init__
(
self
,
user
:
db
.
User
):
self
.
user
=
user
self
.
user
=
user
...
@@ -365,6 +366,12 @@ class Gatekeeper:
...
@@ -365,6 +366,12 @@ class Gatekeeper:
assert
user
.
is_org
or
user
.
is_admin
assert
user
.
is_org
or
user
.
is_admin
self
.
parent_cache
=
{}
self
.
parent_cache
=
{}
self
.
rights_cache
=
{}
self
.
rights_cache
=
{}
self
.
root_place
=
None
def
get_root_place
(
self
)
->
db
.
Place
:
if
not
self
.
root_place
:
self
.
root_place
=
db
.
get_root_place
()
return
self
.
root_place
def
get_ancestors
(
self
,
place
:
db
.
Place
)
->
List
[
db
.
Place
]:
def
get_ancestors
(
self
,
place
:
db
.
Place
)
->
List
[
db
.
Place
]:
pid
=
place
.
place_id
pid
=
place
.
place_id
...
@@ -425,7 +432,7 @@ class Gatekeeper:
...
@@ -425,7 +432,7 @@ class Gatekeeper:
elif
for_place
:
elif
for_place
:
place
=
for_place
place
=
for_place
else
:
else
:
place
=
db
.
get_root_place
()
place
=
self
.
get_root_place
()
rights
=
RoundRights
()
rights
=
RoundRights
()
rights
.
round
=
round
rights
.
round
=
round
rights
.
_clone_from
(
self
.
rights_for
(
rights
.
_clone_from
(
self
.
rights_for
(
...
...
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