-
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
feat: Add REST APIs for course advanced settings and course tabs [BD-38] [TNL-8625] [BB-4132] #27608
feat: Add REST APIs for course advanced settings and course tabs [BD-38] [TNL-8625] [BB-4132] #27608
Conversation
Thanks for the pull request, @xitij2000! I've created BLENDED-841 to keep track of it in Jira. More details are on the BD-38 project page. When this pull request is ready, tag your edX technical lead. |
e3668d1
to
6744cc4
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.
just passing by...
@@ -4,10 +4,12 @@ | |||
|
|||
from django.urls import include, re_path | |||
|
|||
from .v0 import urls as v0_urls |
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.
If we're creating a new API endpoint, shouldn't that use a higher number instead of a lower number?
If the first/pre-existing value was 1, I'd assume the list was 1-indexed and the next number should be 2, not 0.
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've called it v0 because in this case, the API is just exposing an existing endpoint without too much thought put into the structure of the response etc. It's so we can get started with using this from MFEs quicker. I'd expect a v1 of the API as the next iteration that optimises how this works in a way that works better for MFEs.
For instance, I'd expect this API to be split into multiple other APIs, one for each app that can be used to configure it, instead of one single API for all misc operations.
On the other hand, if we can maintain this API as-is, I don't see any reason to not call it v1, and just do the next iteration as v2.
if 'tab_id' in tab_id_locator: | ||
tab = CourseTabList.get_tab_by_id(tab_list, tab_id_locator['tab_id']) | ||
elif 'tab_locator' in tab_id_locator: | ||
tab = get_tab_by_locator(tab_list, tab_id_locator['tab_locator']) | ||
return tab | ||
|
||
|
||
def get_tab_by_locator(tab_list, usage_key_string): | ||
def get_tab_by_locator(tab_list: List[CourseTab], usage_key_string: str) -> Optional[CourseTab]: |
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 dig all the added type hints!
6744cc4
to
621a764
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, only minor suggestions.
@xitij2000 Can you please add a more detailed description of this PR? There are a lot of changes and it seems to me it is exposing an api for advanced settings, but I have no context like, where will this api be used? what fields do we need in the API? etc |
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.
@xitij2000 I had a bunch of questions for this PR, sorry. I am missing some context and information about this PR and linked ticket.
cms/djangoapps/contentstore/rest_api/v0/tests/test_advanced_settings.py
Outdated
Show resolved
Hide resolved
cms/djangoapps/contentstore/rest_api/v0/views/advanced_settings.py
Outdated
Show resolved
Hide resolved
673bd1c
to
ac08deb
Compare
cms/djangoapps/contentstore/rest_api/v0/tests/test_advanced_settings.py
Outdated
Show resolved
Hide resolved
cms/djangoapps/contentstore/rest_api/v0/tests/test_advanced_settings.py
Outdated
Show resolved
Hide resolved
cms/djangoapps/contentstore/rest_api/v0/tests/test_advanced_settings.py
Outdated
Show resolved
Hide resolved
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 @xitij2000 added a few questions and concerns, no major blockers.
807e64c
to
4fcce00
Compare
jenkins run python |
@awaisdar001 Is this good to merge? |
I am taking a look what have left here. |
cbc075e
to
ad6c197
Compare
It is definitely possible, but I think it's a fine balance whether it's more effort to split the PR or review it as is. If it's a matter of review capacity, I think @Agrendalath can help with the review as a core committer. |
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 think we need to address the following concerns / questions before merging this.
- The size (in terms of data) of the v0/advanced_settings is a concern. Its 48kb call comparing with 1.7kb call for pages & resources. Do you think we can cap this call with list of fields/advance settings we need just how e.g. facebook cap the calls to the fields which are most-relevant/requested by end user? Do you think we need all these settings? Can this call be capped? This will help in decreasing the api call size as well as it'd be easier process the data.
we can keep the "Return all fields" feature as well if user doesn't specify any fields, but i think its a good-to-have feature given the data-size.
-
I have a question regarding the params passed for toggling the settings. there are 2 types of params used for the POST request. Query & Post Request params. Can you explain why its make more sense to pass
tab_id=progress
as query param and toggle settingsis_hidden
as request.post param Vs passing both as request.post params? v0/tabs/ -
As python maintains ordering in the list, don't you think it'd be easier to pass ordering as a list of tab_ids? e.g.
[tab_id_1, tab_id_2]
rather the current list-of-objects?
@xitij2000, sure, feel free to ping me if we need an additional review. |
@awaisdar001 The idea was to speed up work on pages and resources, we can take the existing studio APIs for course advanced settings and tabs and expose them via new API endpoints that can be use by MFE. So the aim was for this to be a stopgap v0 API, since it's a small bit of work, and unblocks further progress here. Future iterations of the APIs can be created with a new design. So the size of the API etc are the same as the existing APIs, since it was never the aim to change them. I think the best time to advocate for such a change in approach would have been during the ADR phase, since once it was approved we started work on that basis, and at that stage it would have been easier to build the APIs with these changes in mind.
No we don't need all these settings, and this call can be capped, will update this to add that.
I've split them this way since the tab id or tab location is specifying the resource, while the actual data is part of the post body.
Sure, however we can have a mix of tab ids and tab locations, which are usage keys, so we need to know if it's a tab_id or a tab_location, so we specify it in an object structure to be clear. |
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.
Looks good
@xitij2000 Is this ready to be merged? |
I am currently working on updating the PR to allow partial queries. Will push that change soon. |
6af8912
to
090c727
Compare
I've updated the PR to add support for filtering fields. |
090c727
to
80ab314
Compare
thanks for the improvement @xitij2000 - i'll review the changes on my devstack today. |
Looks good to me 👍 |
This commit adds new APIs that allow MFEs to modify a course's advanced settings and to update tab settings to show/hide/move tabs.
80ab314
to
b707185
Compare
Your PR has finished running tests. There were no failures. |
@awaisdar001 This is good to merge from my side. |
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
EdX Release Notice: This PR has been deployed to the production environment. |
This PR adds new APIs that allow MFEs to access and update course advanced settings, and to get the course tabs and show/hide/reorder them.
Sandbox URL:
Merge deadline: "None"
Testing instructions:
Reviewers
TNL-8625