Skip to content
Snippets Groups Projects
Commit ebd013b7 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Reformat docstrings

parent 4d2ed6e3
No related branches found
No related tags found
1 merge request!113Resolve "Review permissions"
Pipeline #10502 passed
......@@ -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 timetables the user is allowed to access."""
return get_classes(user).exists() or get_rooms(user).exists() or get_teachers(user).exists()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment