Skip to content

Commit

Permalink
Check if there is content in header and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Jun 28, 2024
1 parent 8bb38e2 commit 4a84f88
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ def send_data(self):
self.send_mail(msg=msg, charset=charset)

def prepare_message(self):
from bs4 import BeautifulSoup

mail_header = (self.block.get("mail_header", {}).get("data", None),)
mail_footer = (self.block.get("mail_footer", {}).get("data", None),)

# Check if there is content
mail_header = BeautifulSoup(mail_header).get_text() and mail_header or None
mail_footer = BeautifulSoup(mail_footer).get_text() and mail_footer or None

message_template = api.content.get_view(
name="send_mail_template",
context=self.context,
Expand All @@ -277,8 +286,8 @@ def prepare_message(self):
"parameters": self.filter_parameters(),
"url": self.context.absolute_url(),
"title": self.context.Title(),
"mail_header": self.block.get("mail_header", {}).get('data', None),
"mail_footer": self.block.get("mail_footer", {}).get('data', None),
"mail_header": mail_header,
"mail_footer": mail_footer,
}
return message_template(**parameters)

Expand Down

0 comments on commit 4a84f88

Please sign in to comment.