From e0f63ad2757a082984ef0c7130f85c0470d1f0df Mon Sep 17 00:00:00 2001 From: Syed Muhammad Dawoud Sheraz Ali <40599381+DawoudSheraz@users.noreply.github.com> Date: Mon, 24 Feb 2025 21:51:51 +0500 Subject: [PATCH] fix: send users list in vertical tagging email (#4582) --- course_discovery/apps/tagging/emails.py | 4 ++-- course_discovery/apps/tagging/tests/test_emails.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/course_discovery/apps/tagging/emails.py b/course_discovery/apps/tagging/emails.py index 75d7ef8bb2..0b473b8a4d 100644 --- a/course_discovery/apps/tagging/emails.py +++ b/course_discovery/apps/tagging/emails.py @@ -41,7 +41,7 @@ def send_email_for_course_vertical_assignment(course, to_users): Sends an email to specified users requesting action to assign vertical and sub-vertical for a given course, but only to those who have email notifications enabled. """ - email_enabled_users = [user.email for user in to_users if is_email_notification_enabled(user)] + email_enabled_users = [user for user in to_users if is_email_notification_enabled(user)] if not email_enabled_users: logger.exception( f"Failed to send vertical assignment email for course '{course.title}' (UUID: {course.uuid})" @@ -70,5 +70,5 @@ def send_email_for_course_vertical_assignment(course, to_users): except Exception as e: # pylint: disable=broad-except logger.exception( f"Failed to send vertical assignment email for course '{course.title}' (UUID: {course.uuid}) to " - f"recipients {', '.join(email_enabled_users)}. Error: {str(e)}" + f"recipients {', '.join(list(map(lambda user: user.email, email_enabled_users)))}. Error: {str(e)}" ) diff --git a/course_discovery/apps/tagging/tests/test_emails.py b/course_discovery/apps/tagging/tests/test_emails.py index 56e2c54a82..ed8186e1f3 100644 --- a/course_discovery/apps/tagging/tests/test_emails.py +++ b/course_discovery/apps/tagging/tests/test_emails.py @@ -31,7 +31,7 @@ def test_email_sent_to_recipients(self): self.assertEqual(len(mail.outbox), 1) email = mail.outbox[0] - self.assertEqual(email.to, [self.user1.email, self.user2.email]) + self.assertEqual(email.to, [self.user1, self.user2]) expected_subject = f"Action Required: Assign Vertical and Sub-vertical for Course '{self.course.title}'" self.assertEqual(email.subject, expected_subject)