From f8bf592483db0c4ac5a7da4d7df5edb7b250fb29 Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Thu, 5 Sep 2024 03:01:43 -0700 Subject: [PATCH] fix: added course_id in email sent event (#35422) --- lms/djangoapps/bulk_email/signals.py | 4 +++- .../course_goals/management/commands/goal_reminder_email.py | 1 + openedx/core/djangoapps/schedules/resolvers.py | 1 + openedx/core/djangoapps/schedules/tests/test_resolvers.py | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/bulk_email/signals.py b/lms/djangoapps/bulk_email/signals.py index d45d0ae017bd..afac652debf9 100644 --- a/lms/djangoapps/bulk_email/signals.py +++ b/lms/djangoapps/bulk_email/signals.py @@ -41,7 +41,9 @@ def ace_email_sent_handler(sender, **kwargs): except user_model.DoesNotExist: user_id = None course_email = message.context.get('course_email', None) - course_id = course_email.course_id if course_email else None + course_id = message.context.get('course_id') + if not course_id: + course_id = course_email.course_id if course_email else None tracker.emit( 'edx.bulk_email.sent', { diff --git a/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py b/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py index be344dcb0d9b..0f8227e3201a 100644 --- a/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py +++ b/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py @@ -75,6 +75,7 @@ def send_ace_message(goal): 'email': user.email, 'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME), 'course_name': course_name, + 'course_id': str(goal.course_key), 'days_per_week': goal.days_per_week, 'course_url': course_home_url, 'goals_unsubscribe_url': goals_unsubscribe_url, diff --git a/openedx/core/djangoapps/schedules/resolvers.py b/openedx/core/djangoapps/schedules/resolvers.py index 3498042415ff..5f769e6af299 100644 --- a/openedx/core/djangoapps/schedules/resolvers.py +++ b/openedx/core/djangoapps/schedules/resolvers.py @@ -526,6 +526,7 @@ def get_schedules(self): 'week_num': week_num, 'week_highlights': week_highlights, # This is used by the bulk email optout policy + 'course_id': str(course.id), 'course_ids': [str(course.id)], 'unsubscribe_url': unsubscribe_url, }) diff --git a/openedx/core/djangoapps/schedules/tests/test_resolvers.py b/openedx/core/djangoapps/schedules/tests/test_resolvers.py index 5881861b2282..5c2b592b8e25 100644 --- a/openedx/core/djangoapps/schedules/tests/test_resolvers.py +++ b/openedx/core/djangoapps/schedules/tests/test_resolvers.py @@ -293,6 +293,7 @@ def test_schedule_context(self): 'contact_email': 'info@example.com', 'contact_mailing_address': '123 Sesame Street', 'course_ids': [str(self.course.id)], + 'course_id': str(self.course.id), 'course_name': self.course.display_name, 'course_url': f'http://learning-mfe/course/{self.course.id}/home', 'dashboard_url': '/dashboard',