WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2a850e9

Browse files
separate method to get_message
1 parent 38caf47 commit 2a850e9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

newsletter/models.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def submit(self):
697697
self.sending = False
698698
self.save()
699699

700-
def send_message(self, subscription):
700+
def get_message(self, subscription):
701701
subject, text, html = render_message(
702702
self.message,
703703
date=self.publish_date,
@@ -719,15 +719,17 @@ def send_message(self, subscription):
719719

720720
if html:
721721
message.attach_alternative(html, "text/html")
722+
return message
722723

723-
try:
724-
logger.debug(
725-
gettext('Submitting message to: %s.'),
726-
subscription
727-
)
724+
def send_message(self, subscription):
725+
logger.debug(
726+
gettext('Submitting message to: %s.'),
727+
subscription
728+
)
728729

730+
message = self.get_message(subscription)
731+
try:
729732
message.send()
730-
731733
except Exception as e:
732734
# TODO: Test coverage for this branch.
733735
logger.error(

0 commit comments

Comments
 (0)