Skip to content

Commit

Permalink
feat: add feature flag ENABLE_LIBRARY_DELETION
Browse files Browse the repository at this point in the history
  • Loading branch information
UvgenGen committed Aug 31, 2022
1 parent c385214 commit 40e66b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@
# in the LMS and CMS.
# .. toggle_tickets: 'https://github.com/open-craft/edx-platform/pull/429'
'DISABLE_UNENROLLMENT': False,

# .. toggle_name: FEATURES['ENABLE_LIBRARY_DELETION']
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Set to True to enable deletion functionality for library mfe.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2022-08-31
'ENABLE_LIBRARY_DELETION': False,
}

# .. toggle_name: ENABLE_COPPA_COMPLIANCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def test_list_library(self, is_indexing_enabled):
with override_settings(FEATURES={**settings.FEATURES, 'ENABLE_CONTENT_LIBRARY_INDEX': is_indexing_enabled}):
lib1 = self._create_library(slug="some-slug-1", title="Existing Library")
lib2 = self._create_library(slug="some-slug-2", title="Existing Library")
lib1['can_delete'] = lib2['can_delete'] = True
if not is_indexing_enabled:
lib1['num_blocks'] = lib2['num_blocks'] = None
lib1['last_published'] = lib2['last_published'] = None
Expand Down
11 changes: 6 additions & 5 deletions openedx/core/djangoapps/content_libraries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ def get(self, request):
serializer = ContentLibraryMetadataSerializer(result, many=True)

# add permisson for deleting library in response
for library_data in serializer.data:
library_key = LibraryLocatorV2.from_string(library_data['id'])
library_obj = ContentLibrary.objects.get_by_key(library_key)
can_delete = request.user.has_perm(permissions.CAN_DELETE_THIS_CONTENT_LIBRARY, obj=library_obj)
library_data['can_delete'] = can_delete
if settings.FEATURES.get('ENABLE_LIBRARY_DELETION'):
for library_data in serializer.data:
library_key = LibraryLocatorV2.from_string(library_data['id'])
library_obj = ContentLibrary.objects.get_by_key(library_key)
can_delete = request.user.has_perm(permissions.CAN_DELETE_THIS_CONTENT_LIBRARY, obj=library_obj)
library_data['can_delete'] = can_delete

# Verify `pagination` param to maintain compatibility with older
# non pagination-aware clients
Expand Down

0 comments on commit 40e66b6

Please sign in to comment.