Repository navigation
Conversation
Every /transcripts/* view gets its block through _get_item, which checked the legacy has_course_author_access. Course Editors have no legacy role, so they got a 403 on /transcripts/check and the video editor never showed the YouTube import option. _get_item now checks courses.edit_course_content through user_has_course_permission, with the legacy WRITE permission as fallback, which is the same check as before when the AuthZ flag is off. All of these views back the video editor, so requiring edit permission for all of them matches what the editor already needs. The v0 and v1 REST transcript endpoints reuse check_transcripts and replace_transcripts, so they get the same behavior. Fixes openedx/openedx-authz#597
|
Thanks for the pull request, @efortish! 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. DetailsWhere 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. |
Description
Course Editors can't import YouTube transcripts in the video editor. Every
/transcripts/*view loads its block through_get_item(cms/djangoapps/contentstore/views/transcripts_ajax.py), which checked the legacyhas_course_author_access. Editors are AuthZ-only (no entry inLEGACY_COURSE_ROLE_EQUIVALENCES), so/transcripts/checkreturned 403 for them. The authoring MFE only shows the import card when that call returnscommand == "import"and ignores the failed request, so the option silently never appeared._get_itemnow usesuser_has_course_permission(user, COURSES_EDIT_COURSE_CONTENT, course_key, LegacyAuthoringPermission.WRITE). Whenauthz.enable_course_authoringis off for the course, this falls back tohas_studio_write_access, which is exactly whathas_course_author_accesscalled, so legacy behavior doesn't change.All views that go through
_get_item(check, choose, rename, replace, upload, download) back the video editor, which already requires edit permission, so requiring it for all of them is consistent. The v0 and v1 REST transcript endpoints reusecheck_transcriptsandreplace_transcripts, so they get the same behavior.Roles impacted: Course Author. Course Editors can now check and import transcripts. Users without edit permission (e.g. Course Auditor) still get 403.
Supporting information
openedx-authz.Testing instructions
Automated
New
TestTranscriptsAuthzincms/djangoapps/contentstore/views/tests/test_transcripts.py:/transcripts/check/transcripts/checkor/transcripts/replace/transcripts/check/transcripts/checkWithout the fix, the Editor case fails.
test_transcripts.py(49 tests) and the v1test_youtube_transcripts.py(66 tests) pass in full.Manual (verified on a local Tutor devstack)
Ran against the running LMS and Studio over HTTP (LMS login, SSO into Studio, then the same
GET /transcripts/<view>?data=...calls the video editor makes), on a video block with a YouTube source:authz.enable_course_authoringenabled through a course override, and add a video component.course_editorand anothercourse_auditorin that course./transcripts/checkand/transcripts/replace(import from YouTube)./transcripts/checkon a course with the flag off, using a legacy course staff user and a user with no role.check(AuthZ on)replace/ import (AuthZ on)check/replace(AuthZ on)check(AuthZ off)check(AuthZ off)Note on the import step: in my devstack, YouTube doesn't return a caption track for any video ID, so
replaceends with a 400 ("Can't get transcript link from Youtube") for both the Editor and a legacy course staff user. The Editor now gets exactly the same response as staff, so the permission part works. The 400 comes from the environment's access to YouTube, not from this change.To check it in the UI: log in as a Course Editor on a course with the flag on, open the video editor for a video with a YouTube source that has captions, and the transcript import card should appear.
Deadline
None.
Other information
checkTranscriptsForImportfails) lives infrontend-app-authoringand isn't part of this PR.