From 92b10b564ce211bc609ca6ded62362f9b7fb74f4 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Fri, 29 May 2020 12:48:36 -0400 Subject: [PATCH] Update to handle new format of ManyRelation. --- .../djangoapps/content_libraries/permissions.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/openedx/core/djangoapps/content_libraries/permissions.py b/openedx/core/djangoapps/content_libraries/permissions.py index 555fde0fa0..02f8e2a561 100644 --- a/openedx/core/djangoapps/content_libraries/permissions.py +++ b/openedx/core/djangoapps/content_libraries/permissions.py @@ -17,17 +17,16 @@ is_global_staff = is_user_active & rules.is_staff # Does the user have at least read permission for the specified library? has_explicit_read_permission_for_library = ( ManyRelation( - # In newer versions of bridgekeeper, the 1st and 3rd arguments below aren't needed. - 'permission_grants', 'contentlibrarypermission', ContentLibraryPermission, - Attribute('user', lambda user: user) | Relation('group', Group, in_current_groups) + 'contentlibrarypermission', + (Attribute('user', lambda user: user) | Relation('group', in_current_groups)) ) # We don't check 'access_level' here because all access levels grant read permission ) # Does the user have at least author permission for the specified library? has_explicit_author_permission_for_library = ( ManyRelation( - 'permission_grants', 'contentlibrarypermission', ContentLibraryPermission, - (Attribute('user', lambda user: user) | Relation('group', Group, in_current_groups)) & ( + 'contentlibrarypermission', + (Attribute('user', lambda user: user) | Relation('group', in_current_groups)) & ( Attribute('access_level', ContentLibraryPermission.AUTHOR_LEVEL) | Attribute('access_level', ContentLibraryPermission.ADMIN_LEVEL) ) @@ -36,8 +35,8 @@ has_explicit_author_permission_for_library = ( # Does the user have admin permission for the specified library? has_explicit_admin_permission_for_library = ( ManyRelation( - 'permission_grants', 'contentlibrarypermission', ContentLibraryPermission, - (Attribute('user', lambda user: user) | Relation('group', Group, in_current_groups)) & + 'contentlibrarypermission', + (Attribute('user', lambda user: user) | Relation('group', in_current_groups)) & Attribute('access_level', ContentLibraryPermission.ADMIN_LEVEL) ) )