-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 Library Collections REST endpoints [FC-0062] #35321
feat: Add Library Collections REST endpoints [FC-0062] #35321
Conversation
Thanks for the pull request, @yusuf-musleh! 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. |
fcff07b
to
8c1d5c8
Compare
8c1d5c8
to
f490007
Compare
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
d3f751f
to
743291c
Compare
4f56674
to
59514cc
Compare
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.
Good work here @yusuf-musleh!
I found a small issue while passing invalid library keys and added some other comments.
Let me know what you think!
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/tests/test_views.py
Outdated
Show resolved
Hide resolved
59514cc
to
5bf9422
Compare
@rpenido @pomegranited Thanks for the reviews/comments! I've addressed them all here: 5bf9422 |
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.
Hi @yusuf-musleh , this is working great, but I've requested some structural changes to where the code lives.
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/rest_api/v1/views.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/content_libraries/collections/handlers.py
Outdated
Show resolved
Hide resolved
5bf9422
to
95de012
Compare
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.
LGTM 👍
Thank you for your work, @pomegranited!
Only a nit about updating the key
and improving our error handling.
- I tested this using the instructions from the PR
- I read through the code
-
I checked for accessibility issues - Includes documentation
@@ -136,12 +137,18 @@ def convert_exceptions(fn): | |||
def wrapped_fn(*args, **kwargs): | |||
try: | |||
return fn(*args, **kwargs) | |||
except InvalidKeyError as exc: | |||
log.exception(str(exc)) | |||
raise NotFound # lint-amnesty, pylint: disable=raise-missing-from |
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.
Adding a new collection with the same key/library pair throws django.db.utils.IntegrityError
. Maybe also add it here re-raising as ValidationError
and re-raise as api.LibraryCollectionAlreadyExists
…tions-crud-rest-api
and fixes event types documented in the hooks.
""" | ||
|
||
serializer_class = ContentLibraryCollectionSerializer | ||
lookup_field = 'key' |
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.
@pomegranited Since we plan to make use of object_key
i.e. LibraryCollectionKey
in frontend urls, we should also convert this view to accept LibraryCollectionKey
instead of key
similar to libraries. Provided we really want to include it, as we already have library key in the url in both frontend and backend.
I can do it in a follow up PR if we don't want to block this one.
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.
Same, there are different places where LibraryCollectionKey
can be used. I agree with creating a task for it and doing it when opaque-keys is updated in edx-platform
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.
For now I would prefer to not use the opaque keys in too many places, other than for tagging. We actually tried to avoid using the opaque key completely, except that it's required for tagging. As I mentioned in #35321 (comment) for the URLs and APIs we can generally just accept both a library ID and a key
/slug (not the full opaque key, just the key part) as separate URL parameters. The python APIs can just use the collection integer IDs which is more efficient than huge string keys anyways.
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.
@bradenmacdonald Yes, that is much better.
@pomegranited I created open-craft#683 with some small changes. Those changes are used in openedx/frontend-app-authoring#1259, I've seen that it's easier to add them in this PR. Let me know what you think |
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.
@pomegranited Looks good 👍 I will wait for openedx/openedx-learning#223 and for your review in open-craft#683
* Update description as optional in ContentLibraryCollectionUpdateSerializer * Create collection Rest API to auto-generate key
48a1667
to
e6b469d
Compare
Hi @ChrisChV! Our |
@rpenido Looks good and works well 👍 |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
Good catch on the |
Description
This PR adds REST endpoints (list/create/update/delete) for Library Collections, in addition to emitting events when a library is created/updated. The deleted endpoint and emitting its event will be implemented in a later ticket, however the implementation skeleton is there.
Supporting information
Related Tickets:
Depends on / blocked by:
Testing instructions
lib:SampleTaxonomyOrg1:AL1
{"usage_keys": [ <list of usage keys from the library blocks> ]
{"count": <number of components in list>}
modified
timestamp should be updated.{"usage_keys": [ <list of usage keys from the library blocks> ]
{"count": <number of components in list>}
modified
timestamp should be updated.Private-Ref: FAL-3783