Skip to content

feat: Enrich account activation email with is_enterprise_learner hint - #2674

Merged
pwnage101 merged 1 commit into
masterfrom
mkeating/ENT-11816
Sep 17, 2026
Merged

pwnage101 merged 1 commit into
masterfrom
mkeating/ENT-11816

Conversation

@marlonkeating

@marlonkeating marlonkeating commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Migrate enterprise functionality (populating is_enterprise_learner in Braze email context) from openedx-platform into AccountActivationEmailComposed filter.

This injects the is_enterprise_learner context key which can be used in custom edx themes to influence the activation email template. For 2U, this is only used to trigger an alternative subject line which lacks a goals CTA which is irrelevant to most enterprise learners.

ENT-11816


These should be merged together:


Testing

Setup

Platform settings:

# ENT-11816 temp: disable to exercise the activation-email path locally
# (compose_activation_email / the message_context log line are skipped
# when this is True). Revert to True when done testing.
AUTOMATIC_AUTH_FOR_TESTING = False

Temp logging:

diff --git a/common/djangoapps/student/views/management.py b/common/djangoapps/student/views/management.py
index 6fbbdeb1fb..c59e0cb805 100644
--- a/common/djangoapps/student/views/management.py
+++ b/common/djangoapps/student/views/management.py
@@ -235,6 +235,9 @@ def compose_activation_email(
     __, message_context = AccountActivationEmailComposed.run_filter(
         user=user, message_context=message_context,
     )
+    log.warning("ENT-11816 registration email context for %s after AccountActivationEmailComposed filter "
+                "(is_enterprise_learner=%s): %s",
+                user.username, message_context.get('is_enterprise_learner'), message_context)
 
     if route_enabled:
         dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL']

Non-enterprise user scenario

  1. Navigate to http://localhost:18000/register.
  2. Register.
  3. Verify registration email in logs with is_enterprise=False.

Enterprise user scenario

  1. Navigate to local enterprise customer in admin, and click Manage Learners.
  2. Under the Link learners section, add test email and click Submit.
  3. Navigate to http://localhost:18000/register.
  4. Register test email.
  5. Verify registration email in logs with is_enterprise=True.

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

Implements two new Open edX filter pipeline steps in edx-enterprise to support enterprise-aware account activation behavior (email context enrichment and redirect handling), and wires them into the enterprise filters configuration.

Changes:

  • Added ActivationEmailEnterpriseContextEnricher to populate is_enterprise_learner into activation email message context.
  • Added ActivationRedirectEnterpriseStep to clear redirect_url for non-enterprise learners after activation.
  • Added unit tests and registered both pipelines in ENTERPRISE_FILTERS_CONFIG.

Critical / high severity issue(s):

  • The new pipeline steps call is_enterprise_learner(...) unconditionally, but the module currently sets is_enterprise_learner = None on ImportError. In non-LMS environments (including this repo’s test environment), this can raise TypeError: 'NoneType' object is not callable at runtime unless patched.

Reviewed changes

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

File Description
enterprise/filters/accounts.py Adds the two new account-activation pipeline steps and introduces the cross-boundary is_enterprise_learner import dependency.
enterprise/settings/common.py Registers the new activation-related filter pipelines in ENTERPRISE_FILTERS_CONFIG.
tests/filters/test_accounts.py Adds test coverage for the new activation email context enrichment and redirect-clearing behavior.

Comment thread enterprise/filters/accounts.py Outdated
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.05%. Comparing base (29bdd0d) to head (48e08c0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2674   +/-   ##
=======================================
  Coverage   87.04%   87.05%           
=======================================
  Files         264      264           
  Lines       17272    17278    +6     
  Branches     1707     1707           
=======================================
+ Hits        15035    15041    +6     
  Misses       1898     1898           
  Partials      339      339           
Flag Coverage Δ
unittests 87.05% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marlonkeating
marlonkeating marked this pull request as ready for review August 7, 2026 12:40
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Sep 3, 2026
@openedx-webhooks

openedx-webhooks commented Sep 3, 2026

Copy link
Copy Markdown

Thanks for the pull request, @marlonkeating!

This repository is currently maintained by @openedx/2u-enterprise.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Sep 3, 2026
@pwnage101
pwnage101 marked this pull request as draft September 3, 2026 18:34
@pwnage101
pwnage101 force-pushed the mkeating/ENT-11816 branch 2 times, most recently from cb13dd0 to 67dd6cb Compare September 3, 2026 19:14
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Sep 9, 2026
@pwnage101
pwnage101 marked this pull request as ready for review September 16, 2026 21:41
@pwnage101
pwnage101 requested a balanced review from Copilot September 16, 2026 21:42

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.

🟡 Changes recommended

The advertised AccountActivationCompleted redirect behavior is not implemented or registered.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread enterprise/settings/common.py Outdated
@pwnage101
pwnage101 force-pushed the mkeating/ENT-11816 branch 2 times, most recently from f30acd4 to ecdacc8 Compare September 16, 2026 23:29
@pwnage101 pwnage101 changed the title feat: implement AccountActivationEmailComposed and AccountActivationCompleted filters feat: Enrich account activation email with is_enterprise_learner hint Sep 16, 2026
This adds the ActivationEmailEnterpriseContextEnricher pipeline step for
the AccountActivationEmailContextGenerated filter.

The new pipeline step injects the `is_enterprise_learner` context key
which can be used in custom edx themes to influence the activation email
template.  For 2U, this is only used to trigger an alternative subject
line which lacks a goals CTA (irrelevant to most enterprise learners).

ENT-11816
@pwnage101
pwnage101 merged commit 016d0e5 into master Sep 17, 2026
11 checks passed
@pwnage101
pwnage101 deleted the mkeating/ENT-11816 branch September 17, 2026 20:53
@github-project-automation github-project-automation Bot moved this from Waiting on Author to Done in Contributions Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants