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

Use use_prefetched in predicate

parent 1e374faf
No related branches found
No related tags found
1 merge request!276Resolve "Allow parent group owners to edit lesson documentations/etc. of courses"
......@@ -226,8 +226,8 @@ def is_own_personal_note(user: User, obj: PersonalNote) -> bool:
def is_parent_group_owner(user: User, obj: Group) -> bool:
"""Predicate which checks whether the user is the owner of any parent group of the group."""
if hasattr(obj, "parent_groups"):
for parent_group in obj.parent_groups.all():
if user.person in list(parent_group.owners.all()):
for parent_group in use_prefetched(obj, "parent_groups"):
if user.person in use_prefetched(parent_group, "owners"):
return True
return False
......
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