Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend Emails with Debug if settings.DEBUG #460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions callisto_core/notification/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -375,26 +381,32 @@ 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,
}
)
elif len(self.models_on_site) == 1:
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"],
}
)
Expand Down