diff --git a/src/rer/newsletter/adapter/sender.py b/src/rer/newsletter/adapter/sender.py
index f83e7572..470ac9eb 100644
--- a/src/rer/newsletter/adapter/sender.py
+++ b/src/rer/newsletter/adapter/sender.py
@@ -78,7 +78,7 @@ def _getMessage(self, message, footer):
- {self.context.title}
+ {message.title}
|
""",
@@ -124,14 +124,29 @@ def set_end_send_infos(self, send_uid, completed=True):
send_info = [x for x in details if x["uid"] == send_uid]
if not send_info:
return SEND_UID_NOT_FOUND
- send_info[0]["send_date_end"] = datetime.today().strftime("%d/%m/%Y %H:%M:%S")
+ send_info[0]["send_date_end"] = datetime.today().strftime(
+ "%d/%m/%Y %H:%M:%S"
+ )
send_info[0]["completed"] = completed
send_info[0]["running"] = False
return OK
def prepare_body(self, message):
- unsubscribe_footer_template = self.context.restrictedTraverse(
- "@@unsubscribe_channel_template"
+ # unsubscribe_footer_template = self.context.restrictedTraverse(
+ # "@@unsubscribe_channel_template"
+ # )
+ # parameters = {
+ # "portal_name": get_site_title(),
+ # "channel_name": self.context.title,
+ # "unsubscribe_link": self.context.absolute_url(),
+ # "enabled": self.context.standard_unsubscribe,
+ # }
+ # footer = unsubscribe_footer_template(**parameters)
+ # return self._getMessage(message=message, footer=footer)
+ unsubscribe_footer_template = api.content.get_view(
+ name="unsubscribe_channel_template",
+ context=self.context,
+ request=self.request,
)
parameters = {
"portal_name": get_site_title(),
@@ -139,8 +154,36 @@ def prepare_body(self, message):
"unsubscribe_link": self.context.absolute_url(),
"enabled": self.context.standard_unsubscribe,
}
- footer = unsubscribe_footer_template(**parameters)
- return self._getMessage(message=message, footer=footer)
+
+ message_template = api.content.get_view(
+ context=message, name="messagepreview_view", request=self.request
+ )
+ parameters = {
+ "message_subheader": f"""
+
+
+
+ {message.title}
+
+ |
+
""",
+ "message_unsubscribe_default": f"""
+
+
+
+ {unsubscribe_footer_template(**parameters)}
+
+ |
+
+ """,
+ }
+
+ body = message_template(**parameters)
+ # passo la mail per il transform
+ portal = api.portal.get()
+ body = portal.portal_transforms.convertTo("text/mail", body)
+
+ return body
def sendMessage(self, message):
"""This is the primary method to send emails for the channel."""
@@ -149,7 +192,9 @@ def sendMessage(self, message):
subscribers = self.get_annotations_for_channel(key=SUBSCRIBERS_KEY)
nl_subject = (
- " - " + self.context.subject_email if self.context.subject_email else ""
+ " - " + self.context.subject_email
+ if self.context.subject_email
+ else ""
)
sender = (
self.context.sender_name
@@ -195,7 +240,9 @@ def doSend(self, body, subject, subscribers, sender):
def addToHistory(self, message):
"""Add to history that message is sent"""
- list_history = [x for x in message.workflow_history.get("message_workflow")]
+ list_history = [
+ x for x in message.workflow_history.get("message_workflow")
+ ]
current = api.user.get_current()
entry = dict(
action="Invio",
diff --git a/src/rer/newsletter/browser/channel/templates/mail_templates/active_user.pt b/src/rer/newsletter/browser/channel/templates/mail_templates/active_user.pt
index 2bfe6391..60910461 100644
--- a/src/rer/newsletter/browser/channel/templates/mail_templates/active_user.pt
+++ b/src/rer/newsletter/browser/channel/templates/mail_templates/active_user.pt
@@ -38,15 +38,6 @@
style="width:100%;border:0;border-spacing:0;color:#000"
>
-
-
-
- ${title}
-
- |
-
Per confermare la tua richiesta di iscrizione a Newsletter ${title}, è necessario collegarsi entro 48 ore al seguente link:
${activationUrl}
-
- Cordiali saluti
-
- Redazione del portale ${portal_name}
-
+
+ Cordiali saluti
+
+ Redazione del portale ${portal_name}
+
|
diff --git a/src/rer/newsletter/browser/channel/templates/mail_templates/active_user_confirm.pt b/src/rer/newsletter/browser/channel/templates/mail_templates/active_user_confirm.pt
index c7250ee6..403670d5 100644
--- a/src/rer/newsletter/browser/channel/templates/mail_templates/active_user_confirm.pt
+++ b/src/rer/newsletter/browser/channel/templates/mail_templates/active_user_confirm.pt
@@ -36,15 +36,6 @@
style="width:100%;border:0;border-spacing:0;color:#000"
>
-
-
-
- ${channel_name}
-
- |
-
- L'invio del messaggio ${message_title}
+ L'invio del messaggio ${message_title}
a ${subscribers} iscritti
- del canale ${channel_name} è andato a buon fine.
+ del canale ${channel_name} è andato a buon fine.
diff --git a/src/rer/newsletter/browser/channel/templates/mail_templates/delete_user.pt b/src/rer/newsletter/browser/channel/templates/mail_templates/delete_user.pt
index 3e0f0ecb..22944b76 100644
--- a/src/rer/newsletter/browser/channel/templates/mail_templates/delete_user.pt
+++ b/src/rer/newsletter/browser/channel/templates/mail_templates/delete_user.pt
@@ -37,15 +37,6 @@
style="width:100%;border:0;border-spacing:0;color:#000"
>
- |
-
-
- ${title}
-
- |
-
|