diff --git a/aleksis/apps/chronos/util/predicates.py b/aleksis/apps/chronos/util/predicates.py index 18190d3fbdae1279799643f42aa19909a39d4feb..fb70edee23dbae9f2014634526bea4b7d867adf7 100644 --- a/aleksis/apps/chronos/util/predicates.py +++ b/aleksis/apps/chronos/util/predicates.py @@ -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()