Update to handle new format of ManyRelation.

This commit is contained in:
Diana Huang
2020-05-29 12:48:36 -04:00
parent e3d85bcd74
commit 92b10b564c

View File

@@ -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)
)
)