feat: Invite admin and trigger braze functionality has been updated #2542
Conversation
|
Thanks for the pull request, @rgopalrao-sonata-png! 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:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 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. |
6ed4ddc to
b95d747
Compare
a8c2bf2 to
cecd539
Compare
4d31117 to
c771029
Compare
6989af9 to
4ac677a
Compare
1d8b105 to
0d4bb8c
Compare
|
@rgopalrao-sonata-png I've added you to the openedx-triage team as you are covered under an entity CLA. This will mean that tests will run automatically when you submit a pull request in the future. Please look for an invitation in your email and accept it. |
|
@rgopalrao-sonata-png Looks like there one failed check and some conflicts that need to be resolved. |
|
Thanks for the review — I’ve incorporated the feedback, fixed. Could you please re-review the latest diff |
ENT-11238: Enterprise Admin Invite Flow with Braze Email Integration
Summary
This PR implements the admin invitation and management system for the People Management feature, consolidating multiple related JIRA tickets into a single cohesive solution.
Primary Features:
🎫 Related JIRA Tickets
This PR consolidates the following dependent tickets:
Epic: ENT-10680 - People Management Admin Invite Flow
⚙️ What Changed
Problem Statement
As part of of Invite Admin functionality from people management
Solution Overview
🔹 Workflow 1: Invite Admins (ENT-11238, ENT-11519, ENT-11555)
🔹 Workflow 2: Delete Admins (ENT-11264)
API Changes
New Endpoints
1. Invite Admins
Request Body:
{ "emails": ["admin1@example.com", "admin2@example.com"] }Response (200 OK):
[ {"email": "admin1@example.com", "status": "invite sent"}, {"email": "admin2@example.com", "status": "already admin"} ]Status Values:
"invite sent"- New invitation created"already sent"- Pending invitation exists"already admin"- User is already an active admin2. Delete Admin
Query Parameters:
role(required): Either"pending"or"admin"For
role=pending:PendingEnterpriseCustomerAdminUserrecordFor
role=admin:SystemWideEnterpriseUserRoleAssignmentEnterpriseCustomerUserif no other roles existUseraccount if no roles exist across ALL enterprisesResponse (200 OK):
{ "message": "Admin admin@example.com deleted successfully and user account deactivated", "user_deactivated": true }Modified Endpoints
Deprecated (URL Changed):
Breaking Change: The old endpoint has been removed. Clients must migrate to the new URL pattern.
📁 Key Files Changed
Modified Files
enterprise/api/v1/views/enterprise_customer_admin.py- Invite and delete endpointsenterprise/api/utils.py- Utility functions for admin managemententerprise/api/v1/serializers.py-AdminInviteSerializerfor email validationenterprise/tasks.py-send_enterprise_admin_invite_emailCelery taskenterprise/constants.py- New constants for admin status and Braze endpointstests/test_enterprise/api/test_enterprise_customer_admin.py- Comprehensive test suiteTesting Coverage
Unit Tests Added
✅ Invite Admins Endpoint :
✅ Delete Admin Endpoint:
✅ Braze API Client :
✅ Utility Functions :
Integration Tests
✅ Devstack validation with screenshots (see below)
✅ End-to-end email delivery verification
✅ Multi-admin deletion scenarios
📸 Test Results & Visual Proof
All test scenarios have been validated in devstack. Screenshots demonstrate the functionality:
1. Invitation Already Sent (ENT-11238)
When inviting admins who already have pending invitations, the system correctly identifies them:


✅ Result: Returns
"pending_admin_emails"list instead of creating duplicates2. Email Triggered via Braze (ENT-11519)
New admin invitations successfully trigger Braze email campaigns:

✅ Result: Returns
"inactive_admin_emails"list preventing spam to removed users4. Existing Learner Promotion (ENT-11555)
When inviting existing learners to become admins, they're routed through the learner-to-admin flow:

✅ Result: Existing users get promoted to admin role without re-registration
5. Admin Deletion with ECU Deactivation (ENT-11264)
Role-based deletion correctly deactivates user accounts when no other roles exist:

✅ Result: Returns
"user_deactivated": trueflag confirming soft deleteDeployment Notes
Required Settings
Requires to add the following to your Django settings(edx-internal):
Database Migrations
No database migrations required - uses existing models.
Backward Compatibility
Breaking Change: The old delete admin endpoint URL has changed:
Additional Context