Skip to content

feat: decouple enterprise from courseware view redirects - #338

Merged
pwnage101 merged 1 commit into
release-ulmofrom
pwnage101/ENT-11544-edx-CoursewareViewStarted
Jun 17, 2026
Merged

feat: decouple enterprise from courseware view redirects#338
pwnage101 merged 1 commit into
release-ulmofrom
pwnage101/ENT-11544-edx-CoursewareViewStarted

Conversation

@pwnage101

@pwnage101 pwnage101 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Instead of an enterprise-specific view decorator conditionally redirecting learners to a consent view, plugins can now hook into the CoursewareViewStarted filter to redirect anywhere.

ENT-11544


blocked by:

blocks:


Testing

  1. Invoke ./scripts/provision-integration-test-ENT-11544.sh from test: refactor the seed_enterprise_devstack_data command to be more composable openedx/edx-enterprise#2637
  2. Log in as enterprise_learner_test-enterprise@example.com / edx.
  3. Open the demo course,
  4. Navigate to the programs tab and expect to be redirected:
Screenshot 2026-06-10 at 09 44 15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the enterprise-specific “data sharing consent” redirect decorator from edx-platform courseware/wiki entry points and replaces it with a generic hook point: a new courseware_view_hooks decorator that runs the CoursewareViewStarted filter, allowing plugins (e.g., edx-enterprise) to redirect learners as needed.

Changes:

  • Removed data_sharing_consent_required (and related tests/mixins) from openedx.features.enterprise_support.
  • Added lms.djangoapps.courseware.decorators.courseware_view_hooks and applied it to key courseware and wiki views/middleware.
  • Updated/added tests to assert redirects occur when CoursewareViewStarted raises RedirectToUrl, and refined course_id_from_url typing/docs.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openedx/features/enterprise_support/tests/test_api.py Removes tests tied to the deleted enterprise consent decorator.
openedx/features/enterprise_support/tests/mixins/enterprise.py Removes the consent-redirect testing helper mixin class.
openedx/features/enterprise_support/api.py Deletes the data_sharing_consent_required decorator implementation.
openedx/core/lib/request_utils.py Adds type hints / clarifies behavior for course_id_from_url returning a CourseKey.
lms/djangoapps/discussion/tests/test_views_v2.py Removes enterprise-consent redirect tests for discussion views.
lms/djangoapps/courseware/views/views.py Swaps enterprise decorator for courseware_view_hooks on courseware views (e.g., progress/tab).
lms/djangoapps/courseware/views/index.py Swaps enterprise decorator for courseware_view_hooks on the courseware index view.
lms/djangoapps/courseware/tests/test_views.py Adds test coverage for filter-driven redirects on progress URLs.
lms/djangoapps/courseware/tests/test_view_authentication.py Removes consent mixin inheritance (but currently leaves a broken import; see comments).
lms/djangoapps/courseware/decorators.py Introduces courseware_view_hooks decorator that runs CoursewareViewStarted.
lms/djangoapps/course_wiki/views.py Applies courseware_view_hooks to wiki redirect view instead of enterprise decorator.
lms/djangoapps/course_wiki/tests/tests.py Updates wiki tests for filter-driven redirect (but currently contains merge-conflict markers and a broken import; see comments).
lms/djangoapps/course_wiki/middleware.py Replaces enterprise consent redirect logic with CoursewareViewStarted filter redirect in middleware.
Comments suppressed due to low confidence (1)

lms/djangoapps/course_wiki/tests/tests.py:13

  • This file still imports EnterpriseTestConsentRequired, but that helper class has been removed from openedx.features.enterprise_support.tests.mixins.enterprise. This will raise ImportError when running tests; remove the import.
from lms.djangoapps.courseware.tests.tests import LoginEnrollmentTestCase
from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase  # lint-amnesty, pylint: disable=wrong-import-order

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lms/djangoapps/course_wiki/tests/tests.py Outdated
Comment thread lms/djangoapps/courseware/tests/test_view_authentication.py
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch 2 times, most recently from b370e29 to f480ad8 Compare June 17, 2026 18:04
Copilot AI review requested due to automatic review settings June 17, 2026 18:05
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch from f480ad8 to fd6230e Compare June 17, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

lms/djangoapps/course_wiki/tests/tests.py:13

  • This test file still imports EnterpriseTestConsentRequired, but that mixin has been removed from openedx.features.enterprise_support.tests.mixins.enterprise in this PR. This will raise ImportError and fail the test suite; the import should be removed.
from lms.djangoapps.courseware.tests.tests import LoginEnrollmentTestCase
from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase  # lint-amnesty, pylint: disable=wrong-import-order

Comment thread lms/djangoapps/courseware/decorators.py
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch from fd6230e to cdeb4a4 Compare June 17, 2026 18:12
Copilot AI review requested due to automatic review settings June 17, 2026 18:25
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch from cdeb4a4 to cbb4d0a Compare June 17, 2026 18:25
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch from cbb4d0a to 87c2e6a Compare June 17, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comment thread lms/djangoapps/courseware/decorators.py
@pwnage101 pwnage101 closed this Jun 17, 2026
@pwnage101 pwnage101 reopened this Jun 17, 2026
@pwnage101 pwnage101 closed this Jun 17, 2026
@pwnage101 pwnage101 reopened this Jun 17, 2026
Copilot AI review requested due to automatic review settings June 17, 2026 19:17
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch from 87c2e6a to 20a04b3 Compare June 17, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comment thread lms/djangoapps/courseware/decorators.py Outdated
Instead of an enterprise-specific view decorator conditionally
redirecting learners to a consent view, plugins can now hook into the
CoursewareViewStarted filter to redirect anywhere.

ENT-11544
@pwnage101
pwnage101 force-pushed the pwnage101/ENT-11544-edx-CoursewareViewStarted branch from 20a04b3 to 3a8bceb Compare June 17, 2026 19:41
@pwnage101
pwnage101 enabled auto-merge June 17, 2026 19:56
@pwnage101
pwnage101 merged commit 196e593 into release-ulmo Jun 17, 2026
64 checks passed
@pwnage101
pwnage101 deleted the pwnage101/ENT-11544-edx-CoursewareViewStarted branch June 17, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants