Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Chronos
Commits
ebd013b7
Commit
ebd013b7
authored
3 years ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Reformat docstrings
parent
4d2ed6e3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!113
Resolve "Review permissions"
Pipeline
#10502
passed
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/chronos/util/predicates.py
+25
-5
25 additions, 5 deletions
aleksis/apps/chronos/util/predicates.py
with
25 additions
and
5 deletions
aleksis/apps/chronos/util/predicates.py
+
25
−
5
View file @
ebd013b7
...
...
@@ -12,7 +12,12 @@ from .chronos_helpers import get_classes, get_rooms, get_teachers
@predicate
def
has_timetable_perm
(
user
:
User
,
obj
:
Model
)
->
bool
:
"""
Predicate which checks whether the user is allowed to access the requested timetable.
"""
"""
Check if can access timetable.
Predicate which checks whether the user is allowed
to access the requested timetable.
"""
if
isinstance
(
obj
,
Group
):
return
has_group_timetable_perm
(
user
,
obj
)
elif
isinstance
(
obj
,
Person
):
...
...
@@ -25,7 +30,12 @@ def has_timetable_perm(user: User, obj: Model) -> bool:
@predicate
def
has_group_timetable_perm
(
user
:
User
,
obj
:
Group
)
->
bool
:
"""
Predicate which checks whether the user is allowed to access the requested group timetable.
"""
"""
Check if can access group timetable.
Predicate which checks whether the user is allowed
to access the requested group timetable.
"""
return
(
obj
in
user
.
person
.
member_of
.
all
()
or
user
.
person
.
primary_group
==
obj
...
...
@@ -37,7 +47,12 @@ def has_group_timetable_perm(user: User, obj: Group) -> bool:
@predicate
def
has_person_timetable_perm
(
user
:
User
,
obj
:
Person
)
->
bool
:
"""
Predicate which checks whether the user is allowed to access the requested person timetable.
"""
"""
Check if can access person timetable.
Predicate which checks whether the user is allowed
to access the requested person timetable.
"""
return
(
user
.
person
==
obj
or
has_global_perm
(
"
chronos.view_all_person_timetables
"
)(
user
)
...
...
@@ -47,7 +62,12 @@ def has_person_timetable_perm(user: User, obj: Person) -> bool:
@predicate
def
has_room_timetable_perm
(
user
:
User
,
obj
:
Room
)
->
bool
:
"""
Predicate which checks whether the user is allowed to access the requested room timetable.
"""
"""
Check if can access room timetable.
Predicate which checks whether the user is allowed
to access the requested room timetable.
"""
return
has_global_perm
(
"
chronos.view_all_room_timetables
"
)(
user
)
or
has_object_perm
(
"
chronos.view_room_timetable
"
)(
user
,
obj
)
...
...
@@ -55,5 +75,5 @@ def has_room_timetable_perm(user: User, obj: Room) -> bool:
@predicate
def
has_any_timetable_object
(
user
:
User
)
->
bool
:
"""
Predicate which checks whether there
exists a
timetable
that
the user is allowed to access.
"""
"""
Predicate which checks whether there
are any
timetable
s
the user is allowed to access.
"""
return
get_classes
(
user
).
exists
()
or
get_rooms
(
user
).
exists
()
or
get_teachers
(
user
).
exists
()
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