Skip to content

Commit

Permalink
Fix links (#63)
Browse files Browse the repository at this point in the history
* Fix links

* Update post.py

* Unused var
  • Loading branch information
folix-01 authored Aug 6, 2024
1 parent e4002f3 commit 33cc7fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
3.1.1 (unreleased)
------------------

- Fix mail header and footer links.
[folix-01]
- Plone5 compatibility in the upgradesteps
[folix-01]
- Install otp package by upgradestep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,27 @@ def prepare_message(self):
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
bs_mail_header = BeautifulSoup(mail_header)
bs_mail_footer = BeautifulSoup(mail_footer)

portal = getMultiAdapter(
(self.context, self.request), name="plone_portal_state"
).portal()

frontend_domain = api.portal.get_registry_record(
name="volto.frontend_domain", default=""
)

for snippet in [bs_mail_header, bs_mail_footer]:
if snippet:
for link in snippet.find_all("a"):
if link.get("href", "").startswith("/"):
link["href"] = (
frontend_domain or portal.absolute_url() + link["href"]
)

mail_header = bs_mail_header.get_text() and bs_mail_header.prettify() or None
mail_footer = bs_mail_footer.get_text() and bs_mail_footer.prettify() or None

email_format_page_template_mapping = {
"list": "send_mail_template",
Expand Down

0 comments on commit 33cc7fa

Please sign in to comment.