-
Notifications
You must be signed in to change notification settings - Fork 4k
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: api for adding, removing and updating components in container #36434
feat: api for adding, removing and updating components in container #36434
Conversation
Thanks for the pull request, @navinkarkera! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are 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. 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. |
f82a882
to
6f298a5
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, @navinkarkera!
- I tested this using the instructions from the PR, and manually calling the endpoint
- I read through the code
- I checked for accessibility issues
- Includes documentation
""" | ||
Creates, updates, or deletes the document for the given Library Container in the search index. | ||
|
||
TODO: add support for indexing a container's components, like upsert_library_collection_index_doc does. |
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.
This would be part of another task?
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.
Not sure if we need this right now as search is not planned yet for units. If we add containers to each component index document similar to collections, we'll need to update this function to reindex each child component.
6f298a5
to
2cfdbad
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.
Hi @navinkarkera -- this is looking really good for the "add existing components to a container" use case, but we're missing a view that lets us "add new component to a container".
Have a couple more concerns inline, please feel free to push back.
Note to self: code review done by comparing to braden/units-api
) | ||
|
||
|
||
def get_container(container_key: LibraryContainerLocator) -> authoring_models.Container: |
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.
@navinkarkera I think our API should still only return ContainerMetadata as originally designed.
But see https://github.com/open-craft/edx-platform/pull/757/files#diff-5a248b18ae17c86d454776cb48e0372a8cbdc9610b3886f175a116f9b280e681R118 -- I did end up adding an internal method to get the Container object to save some code duplication. Feel free to pull in that code?
Open for discussion.
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.
Nice! I had initially used it outside of the file, but changed it later on. I'll pull changes from 757.
return container | ||
|
||
|
||
def get_container_metadata(container_key: LibraryContainerLocator) -> ContainerMetadata: |
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.
See above -- get_container
should return ContainerMetadata, so no need for this added method.
published_by: str = "" | ||
last_draft_created: datetime | None = None | ||
# The username of the user who created the last draft. | ||
last_draft_created_by: str = "" | ||
has_unpublished_changes: bool = False | ||
collections: list[CollectionMetadata] = field(default_factory=list) | ||
can_stand_alone: bool = True |
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 we should expose can_stand_alone
on the dataclasses -- it's for internal use only.
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.
See below: #36434 (comment), we need the frontend to set this flag to False
whenever a new component is created under a container like unit.
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.
Ah ok -- I missed that subtlety, that's fine :)
But could you add some documentation about the parameters to create_library_block
to explain what this flag is for to users of the API?
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 Done. cb9ea4f
@@ -298,7 +342,7 @@ def to_internal_value(self, value: str) -> UsageKeyV2: | |||
raise ValidationError from err | |||
|
|||
|
|||
class ContentLibraryCollectionComponentsUpdateSerializer(serializers.Serializer): | |||
class ContentLibraryComponentKeysSerializer(serializers.Serializer): |
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.
Ah, that's better, thank you. :)
2cfdbad
to
5950aed
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.
👍 Thank you for answering my questions @navinkarkera !
Just one nit re documentation for create_library_block
, since we're exposing that can_stand_alone
flag, but this looks and works great.
-
I tested this-- I checked that the functionality is covered by unit tests - I read through the code by comparing against
braden/units-api
-
I checked for accessibility issues by using my keyboard to navigateN/A - Includes documentation
- User-facing strings are extracted for translation
cb9ea4f
to
8e004fa
Compare
8e004fa
to
d1d5b8e
Compare
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. |
Description
Rest API to add, remove and update components under containers in content libraries.
Useful information to include:
Supporting information
Private-ref
: FAL-4109Testing instructions
Deadline
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.
Concerns
Enforce restrictions on which block types are allowed.: Not sure about this one. Do we have a fixed list of allowed blocks that we want to restrict via rest api or is this configurable per unit/library etc.?