Skip to content

Commit

Permalink
Update post.py
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Jun 28, 2024
1 parent 652fb25 commit 12a95cd
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,15 @@ def send_data(self):
self.send_mail(msg=acknowledgement_mail, charset=charset)

def prepare_message(self):
from bs4 import BeautifulSoup

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

# 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

email_format_page_template_mapping = {
"list": "send_mail_template",
"table": "send_mail_template_table",
Expand All @@ -413,8 +422,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', {}),
"mail_footer": self.block.get("mail_footer", {}).get('data', {}),
"mail_header": mail_header,
"mail_footer": mail_footer,
}
return message_template(**parameters)

Expand Down

0 comments on commit 12a95cd

Please sign in to comment.