Skip to content

Commit e7377d4

Browse files
authored
fix: add additional kwargs to USER_RETIRE_LMS (#38078)
1 parent f802f57 commit e7377d4

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

lms/djangoapps/program_enrollments/tests/test_signals.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ def test_idempotent(self):
100100

101101
self.assert_enrollment_and_history_retired(enrollment)
102102

103+
def test_retire_signal_handler_tolerates_extra_kwargs(self):
104+
"""
105+
Ensure program_enrollments retirement receiver does not break with additional kwargs.
106+
"""
107+
enrollment = self.create_enrollment_and_history()
108+
109+
# Simulate the signal being sent with extra kwargs.
110+
_listen_for_lms_retire(
111+
sender=self.__class__,
112+
user=enrollment.user,
113+
retired_username='retired-test-username',
114+
retired_email='[email protected]',
115+
)
116+
117+
self.assert_enrollment_and_history_retired(enrollment)
118+
103119

104120
@ddt.ddt
105121
class SocialAuthEnrollmentCompletionSignalTest(CacheIsolationTestCase):

openedx/core/djangoapps/user_api/accounts/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
USER_RETIRE_MAILINGS = Signal()
1111

1212
# Signal to retire LMS critical information
13-
# providing_args=["user"]
13+
# providing_args=["user", "retired_username", "retired_email"]
1414
USER_RETIRE_LMS_CRITICAL = Signal()
1515

1616
# Signal to retire LMS misc information

openedx/core/djangoapps/user_api/accounts/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,12 @@ def post(self, request):
11701170
UnregisteredLearnerCohortAssignments.delete_by_user_value(original_email, field="email")
11711171

11721172
# This signal allows code in higher points of LMS to retire the user as necessary
1173-
USER_RETIRE_LMS_CRITICAL.send(sender=self.__class__, user=user)
1173+
USER_RETIRE_LMS_CRITICAL.send(
1174+
sender=self.__class__,
1175+
user=user,
1176+
retired_username=retired_username,
1177+
retired_email=retired_email,
1178+
)
11741179

11751180
user.first_name = ""
11761181
user.last_name = ""

0 commit comments

Comments
 (0)