From a9c78cd8f71b0e9d3e3c345d3adaedbd40e260d1 Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Thu, 29 May 2025 17:52:28 +0500 Subject: [PATCH] chore: modified notification digest email UI (#36809) * chore: modified notification digest email UI * chore: added icon in settings * refactor: replaced CADENCE with DIGEST for logo variable --- lms/envs/common.py | 1 + .../notifications/email/notification_icons.py | 5 +++- .../djangoapps/notifications/email/utils.py | 26 ++++++++++++------- .../notifications/digest_content.html | 2 +- .../notifications/digest_footer.html | 2 +- .../notifications/digest_header.html | 6 ++--- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 0114bc249c..5dfe7a85aa 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -5407,6 +5407,7 @@ NOTIFICATION_CREATION_BATCH_SIZE = 76 NOTIFICATIONS_DEFAULT_FROM_EMAIL = "no-reply@example.com" NOTIFICATION_TYPE_ICONS = {} DEFAULT_NOTIFICATION_ICON_URL = "" +NOTIFICATION_DIGEST_LOGO = DEFAULT_EMAIL_LOGO_URL ############## NUDGE EMAILS ############### # .. setting_name: DISABLED_ORGS_FOR_PROGRAM_NUDGE diff --git a/openedx/core/djangoapps/notifications/email/notification_icons.py b/openedx/core/djangoapps/notifications/email/notification_icons.py index 0336a43a81..2b420d7109 100644 --- a/openedx/core/djangoapps/notifications/email/notification_icons.py +++ b/openedx/core/djangoapps/notifications/email/notification_icons.py @@ -11,6 +11,7 @@ class NotificationTypeIcons: CHECK_CIRCLE_GREEN = "CHECK_CIRCLE_GREEN" HELP_OUTLINE = "HELP_OUTLINE" NEWSPAPER = "NEWSPAPER" + OPEN_RESPONSE_OUTLINE = "OPEN_RESPONSE_OUTLINE" POST_OUTLINE = "POST_OUTLINE" QUESTION_ANSWER_OUTLINE = "QUESTION_ANSWER_OUTLINE" REPORT_RED = "REPORT_RED" @@ -32,7 +33,9 @@ class NotificationTypeIcons: "content_reported": cls.REPORT_RED, "response_endorsed_on_thread": cls.VERIFIED, "response_endorsed": cls.CHECK_CIRCLE_GREEN, - "course_update": cls.NEWSPAPER, + "course_updates": cls.NEWSPAPER, + "ora_staff_notifications": cls.OPEN_RESPONSE_OUTLINE, + "ora_grade_assigned": cls.OPEN_RESPONSE_OUTLINE, } return notification_type_dict.get(notification_type, default) diff --git a/openedx/core/djangoapps/notifications/email/utils.py b/openedx/core/djangoapps/notifications/email/utils.py index efacf8aee4..d0a5a8e0d6 100644 --- a/openedx/core/djangoapps/notifications/email/utils.py +++ b/openedx/core/djangoapps/notifications/email/utils.py @@ -101,6 +101,7 @@ def create_email_template_context(username): "platform_name": settings.PLATFORM_NAME, "mailing_address": settings.CONTACT_MAILING_ADDRESS, "logo_url": get_logo_url_for_email(), + "logo_notification_cadence_url": settings.NOTIFICATION_DIGEST_LOGO, "social_media": social_media_info, "notification_settings_url": f"{settings.ACCOUNT_MICROFRONTEND_URL}/#notifications", "unsubscribe_url": get_unsubscribe_link(username, patch) @@ -120,19 +121,25 @@ def create_email_digest_context(app_notifications_dict, username, start_date, en context = create_email_template_context(username) start_date_str = create_datetime_string(start_date) end_date_str = create_datetime_string(end_date if end_date else start_date) - email_digest_updates = [{ - 'title': 'Total Notifications', - 'translated_title': _('Total Notifications'), - 'count': sum(value['count'] for value in app_notifications_dict.values()) - }] - email_digest_updates.extend([ + email_digest_updates = [ { 'title': value['title'], 'count': value['count'], 'translated_title': value.get('translated_title', value['title']), } for key, value in app_notifications_dict.items() - ]) + ] + lookup = { + 'Updates': 1, + 'Grading': 2, + 'Discussion': 3, + } + email_digest_updates.sort(key=lambda x: lookup.get(x['title'], 4), reverse=False) + email_digest_updates.append({ + 'title': 'Total Notifications', + 'translated_title': _('Total Notifications'), + 'count': sum(value['count'] for value in app_notifications_dict.values()) + }) email_content = [] notifications_in_app = 5 @@ -245,6 +252,7 @@ def add_additional_attributes_to_notifications(notifications, courses_data=None) notification.time_ago = get_time_ago(notification.created) notification.email_content = add_zero_margin_to_root(notification.content) notification.details = add_zero_margin_to_root(notification.content_context.get('email_content', '')) + notification.view_text = get_text_for_notification_type(notification_type) return notifications @@ -447,7 +455,7 @@ def get_translated_app_title(name): mapping = { 'discussion': _('Discussion'), 'updates': _('Updates'), - 'grading': _('Grading'), + 'grading': _('Grades'), } return mapping.get(name, '') @@ -468,7 +476,7 @@ def get_text_for_notification_type(notification_type): if not app_name: return "" mapping = { - 'discussion': _('post'), + 'discussion': _('discussion'), 'updates': _('update'), 'grading': _('assessment'), } diff --git a/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html b/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html index a4de0b6b0a..d951de10be 100644 --- a/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html +++ b/openedx/core/djangoapps/notifications/templates/notifications/digest_content.html @@ -47,7 +47,7 @@ - {% trans "View" as tmsg %}{{ tmsg | force_escape }} + {% trans "View" as tmsg %}{{ tmsg | force_escape }} {{ notification.view_text|default:""}} diff --git a/openedx/core/djangoapps/notifications/templates/notifications/digest_footer.html b/openedx/core/djangoapps/notifications/templates/notifications/digest_footer.html index 76c118f98c..ae5c6b4699 100644 --- a/openedx/core/djangoapps/notifications/templates/notifications/digest_footer.html +++ b/openedx/core/djangoapps/notifications/templates/notifications/digest_footer.html @@ -7,7 +7,7 @@ - Logo + Logo diff --git a/openedx/core/djangoapps/notifications/templates/notifications/digest_header.html b/openedx/core/djangoapps/notifications/templates/notifications/digest_header.html index a1963335fa..71443b6fb1 100644 --- a/openedx/core/djangoapps/notifications/templates/notifications/digest_header.html +++ b/openedx/core/djangoapps/notifications/templates/notifications/digest_header.html @@ -15,16 +15,16 @@
- logo_url + logo_url
{% if digest_frequency == "Weekly" %} - {% trans "Weekly email digest" as tmsg %}{{ tmsg | force_escape }} + {% trans "Weekly Notifications Digest" as tmsg %}{{ tmsg | force_escape }} {% else %} - {% trans "Daily email digest" as tmsg %}{{ tmsg | force_escape }} + {% trans "Daily Notifications Digest" as tmsg %}{{ tmsg | force_escape }} {% endif %}