From e7c1a2d0c93ae7c366cbe9db6fa6bc3584810e38 Mon Sep 17 00:00:00 2001 From: PropeReferio Date: Tue, 27 Oct 2020 21:17:38 -0500 Subject: [PATCH] Prepend Emails with Debug if settings.DEBUG --- callisto_core/notification/api.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/callisto_core/notification/api.py b/callisto_core/notification/api.py index 25a97b123..f61592d1a 100644 --- a/callisto_core/notification/api.py +++ b/callisto_core/notification/api.py @@ -75,6 +75,12 @@ def prepend_subject_if_demo_mode(self, subject): else: return subject + def prepend_subject_if_debug(self, subject): + if settings.DEBUG: + return f'[DEBUG]' {subject}" + else: + return subject + def user_site_id(self, user): return user.account.site_id @@ -375,9 +381,11 @@ def set_notification(self): self.context.update( { "notification_name": self.context["email_template_name"], - "subject": self.prepend_subject_if_demo_mode( - self.context["email_subject"] - ), + "subject": self.prepend_subject_if_debug( + self.prepend_subject_if_demo_mode( + self.context["email_subject"] + ) + ), "body": body, } ) @@ -385,16 +393,20 @@ def set_notification(self): notification = self.models_on_site[0] self.context.update( { - "subject": self.prepend_subject_if_demo_mode(notification.subject), + "subject": self.prepend_subject_if_debug( + self.prepend_subject_if_demo_mode(notification.subject) + ), "body": notification.body, } ) else: self.context.update( { - "subject": self.prepend_subject_if_demo_mode( - self.context["notification_name"] - ), + "subject": self.prepend_subject_if_debug( + self.prepend_subject_if_demo_mode( + self.context["notification_name"] + ) + ), "body": self.context["notification_name"], } )