add staff exemption for content access in library access

This commit is contained in:
DawoudSheraz
2019-02-13 15:19:32 +05:00
parent 44bfbba135
commit 24d63f25ce
2 changed files with 20 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo
blocks within a library_content module to which a user should not
have access.
Staff users are *not* exempted from library content pathways.
Staff users are to exempted from library content pathways.
"""
WRITE_VERSION = 1
READ_VERSION = 1
@@ -123,8 +123,10 @@ class ContentLibraryTransformer(FilteringTransformerMixin, BlockStructureTransfo
Return True if selected block should be removed.
Block is removed if it is part of library_content, but has
not been selected for current user.
not been selected for current user, with staff as an exemption.
"""
if usage_info.has_staff_access:
return False
if block_key not in all_library_children:
return False
if block_key in all_selected_children:

View File

@@ -164,3 +164,19 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase):
),
u"Expected 'selected' equality failed in iteration {}.".format(i)
)
def test_staff_access_to_library_content(self):
"""
To verify that staff member has access to all the library content blocks.
Scenario: Given a staff member in a course with library content
when data is transformed by LibraryContentTransformer
none of the unassigned block is removed from the access list
and staff member will have access to all the blocks
"""
transformed_blocks = get_course_blocks(
self.staff,
self.course.location,
transformers=self.transformers
)
self.assertEqual(len(list(transformed_blocks.get_block_keys())), len(self.blocks))