-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soft delete collections #35496
base: master
Are you sure you want to change the base?
Soft delete collections #35496
Conversation
Thanks for the pull request, @pomegranited! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
dd78988
to
12e104b
Compare
This change standardises the search document "id" to be a meilisearch ID generated from the usage key, for all types of indexed objects. This is important for collections so we can locate the collection document in the search index solely from the data provided by the LIBRARY_COLLECTION_DELETED event (library_key + collection_key), even if the collection has been deleted from the database.
* get_library_collection_usage_key and searchable_doc_tags_for_collection do not need a Collection object; the usage key can be created from the library_key and collection_key. * updated searchable_doc_for_collection to require the parts of the collection usage key + an optional collection. This allows us to identify the collection's search document from its usage key without requiring an existing Collection object (in case it's been deleted). Also removes the edge case for indexing Collections not associated with a ContentLibrary -- this won't ever really happen.
so that added/removed collections are removed/re-added to component documents. Special case: When a collection is soft-deleted/restored, we detect this in the search index and update the collection's component documents directly, without a CONTENT_OBJECT_ASSOCIATON_CHANGED signal.
12e104b
to
494d1a7
Compare
@@ -1103,8 +1100,7 @@ def create_library_collection( | |||
content_library: ContentLibrary | None = None, | |||
) -> Collection: | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need create_library_collection
and update_library_collection
API methods now? They're just wrappers for the authoring_api methods now that we're not sending events anymore.
@@ -93,7 +93,7 @@ libsass==0.10.0 | |||
click==8.1.6 | |||
|
|||
# pinning this version to avoid updates while the library is being developed | |||
openedx-learning==0.11.5 | |||
openedx-learning @ git+https://github.com/open-craft/openedx-learning.git@jill/collection-delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do: fix this when PR merges.
@pomegranited The code looks good. When testing the "soft delete" and "hard delete" with the admin panel, it don't update the index: https://www.loom.com/share/115ac6dcc9504200b6c58cf3ed97a358?sid=2280dbda-8be2-4bb2-a630-714e5a2cf5ab |
Description
Adds support for soft-deleting and restoring Collections.
As part of this change, we're refactoring the way the Collections-related events are triggered to use Django model signals, so that changes made in Django Admin will be reflected in the Studio search index.
Supporting information
Related to: openedx/modular-learning#231
Depends on: openedx/openedx-learning#229
Private-ref: FAL-3809
Testing instructions
tutor dev run cms ./manage.py cms reindex_studio --experimental
Your api key can be found with tutor config printvalue MEILISEARCH_API_KEY
Search for your collection key and verify that the collection document and its components are returned.
Note that the collection no longer appears in the Authoring MFE list of collections.
Search for your collection key in Meilisearch and verify that no results are found.
Verify that the collection again appears in the Authoring MFE list of collections.
Search for your collection key in Meilisearch and verify that the collection document and its components are returned again.
Disabling a collection should have the same effect as the "soft delete" REST API (step 4).
Re-enabling a collection should have the same effect as the "restore" REST API (step 5)
This will permanently delete the Collection.
This should return a 404.
Deadline
ASAP
Author Notes & Concerns
Collection.pk
to a string generated from the Collection's usage key.We needed to do this so that the Collection document could be identified by the information in the
CONTENT_LIBRARY_DELETED
event (library_key
+collection_key
), so this document can be removed after the Collection itself is removed.Users will need to reindex their studio search content.