forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: Add REST endpoints to update Components in a Collections (temp) #674
Merged
pomegranited
merged 28 commits into
yusuf-musleh/collections-crud-rest-api
from
jill/collection-components-rest
Sep 3, 2024
Merged
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f58bb67
feat: Add Library Collections REST endpoints
yusuf-musleh f490007
test: Add tests for Collections REST APIs
yusuf-musleh 17933a1
chore: Add missing __init__ files
yusuf-musleh 743291c
feat: Verify collection belongs to library
yusuf-musleh 3da44d5
feat: Add events emitting for Collections
yusuf-musleh 59514cc
chore: fix pylint errors
yusuf-musleh 250434f
chore: update openedx-learning
pomegranited f4521b5
feat: add/remove components to/from a collection
pomegranited 129bcf2
refactor: use "components" not "contents"
pomegranited e8013eb
refactor: use oel_collections.get_collections
pomegranited 94890db
fix: pylint/type error
pomegranited 6ded8a9
test: adds tests for api.update_collection_components
pomegranited 0d8079c
test: fixes failing test
pomegranited fe43b72
feat: Add Library Collections REST endpoints
yusuf-musleh f5900be
test: Add tests for Collections REST APIs
yusuf-musleh 97739c6
chore: Add missing __init__ files
yusuf-musleh 2996a2e
feat: Verify collection belongs to library
yusuf-musleh fbfd983
feat: Add events emitting for Collections
yusuf-musleh cf9e906
chore: fix pylint errors
yusuf-musleh 5bf9422
refactor: Use convert_exceptions + update tests
yusuf-musleh ea24e2f
Merge remote-tracking branch 'opencraft/yusuf-musleh/collections-crud…
pomegranited 8034861
refactor: index collections within each library
pomegranited 55338e1
test: fix flaky test
pomegranited 23f5d5b
refactor: adapt to oel_collection.update_collection_components changes
pomegranited 0a1732e
Merge branch 'yusuf-musleh/collections-crud-rest-api' into jill/colle…
pomegranited addde52
refactor: moved code around after merging base
pomegranited 51f5c1a
refactor: simplify the REST API params and validation
pomegranited 7a8e4c6
chore: uses openedx-learning==0.11.3
pomegranited File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
57 changes: 57 additions & 0 deletions
57
openedx/core/djangoapps/content_libraries/collections/handlers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Signal handlers for Content Library Collections. | ||
""" | ||
|
||
import logging | ||
|
||
from django.dispatch import receiver | ||
from openedx_events.content_authoring.data import LibraryCollectionData | ||
from openedx_events.content_authoring.signals import ( | ||
LIBRARY_COLLECTION_CREATED, | ||
LIBRARY_COLLECTION_UPDATED, | ||
LIBRARY_COLLECTION_DELETED, | ||
) | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@receiver(LIBRARY_COLLECTION_CREATED) | ||
def library_collection_created_handler(**kwargs): | ||
""" | ||
Content Library Collection Created signal handler | ||
""" | ||
library_collection_data = kwargs.get("library_collection", None) | ||
if not library_collection_data or not isinstance(library_collection_data, LibraryCollectionData): | ||
log.error("Received null or incorrect data for event") | ||
return | ||
|
||
log.info("Received Collection Created Signal") | ||
|
||
# TODO: Implement handler logic | ||
|
||
|
||
@receiver(LIBRARY_COLLECTION_UPDATED) | ||
def library_collection_updated_handler(**kwargs): | ||
""" | ||
Content Library Collection Updated signal handler | ||
""" | ||
library_collection_data = kwargs.get("library_collection", None) | ||
if not library_collection_data or not isinstance(library_collection_data, LibraryCollectionData): | ||
log.error("Received null or incorrect data for event") | ||
return | ||
|
||
log.info("Received Collection Updated Signal") | ||
|
||
|
||
@receiver(LIBRARY_COLLECTION_DELETED) | ||
def library_collection_deleted_handler(**kwargs): | ||
""" | ||
Content Library Collection Deleted signal handler | ||
""" | ||
library_collection_data = kwargs.get("library_collection", None) | ||
if not library_collection_data or not isinstance(library_collection_data, LibraryCollectionData): | ||
log.error("Received null or incorrect data for event") | ||
return | ||
|
||
log.info("Received Collection Deleted Signal") |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think I get why we are dispatchingCONTENT_OBJECT_TAGS_CHANGED
here. Maybe you meanLIBRARY_COLLECTION_UPDATED
?Note: There is a discussion about this event here.
Edit: Now I saw that this came from the issue description. But I don't see any benefit from using this event. Currently, it updates only the tag data (ref), not the metadata of the document (that we would need here)
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.
@rpenido Yep, that's the current behaviour, but we're planning to update it with openedx/modular-learning#230. I've made a start at that here: jill/collection-components-rest...open-craft:edx-platform:jill/collection-components-search
But will see how that discussion shakes out.
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.
@rpenido I will rename
CONTENT_OBJECT_TAGS_CHANGED
toCONTENT_OBJECT_ASSOCIATIONS_CHANGED
, and add a field indicating whether it was thetag
orcollection
that changed when I do openedx/modular-learning#230.