Merge pull request #12253 from pateljannat/newsletter-modifications

feat: Newsletter modifications
This commit is contained in:
mergify[bot] 2021-02-25 10:07:31 +00:00 committed by GitHub
commit 64abd9d3e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 8 deletions

View file

@ -470,8 +470,8 @@ def get_request_header(key, default=None):
def sendmail(recipients=[], sender="", subject="No Subject", message="No Message",
as_markdown=False, delayed=True, reference_doctype=None, reference_name=None,
unsubscribe_method=None, unsubscribe_params=None, unsubscribe_message=None,
attachments=None, content=None, doctype=None, name=None, reply_to=None,
unsubscribe_method=None, unsubscribe_params=None, unsubscribe_message=None, add_unsubscribe_link=1,
attachments=None, content=None, doctype=None, name=None, reply_to=None, queue_separately=False,
cc=[], bcc=[], message_id=None, in_reply_to=None, send_after=None, expose_recipients=None,
send_priority=1, communication=None, retry=1, now=None, read_receipt=None, is_notification=False,
inline_images=None, template=None, args=None, header=None, print_letterhead=False, with_container=False):
@ -518,10 +518,10 @@ def sendmail(recipients=[], sender="", subject="No Subject", message="No Message
from frappe.email import queue
queue.send(recipients=recipients, sender=sender,
subject=subject, message=message, text_content=text_content,
reference_doctype = doctype or reference_doctype, reference_name = name or reference_name,
reference_doctype = doctype or reference_doctype, reference_name = name or reference_name, add_unsubscribe_link=add_unsubscribe_link,
unsubscribe_method=unsubscribe_method, unsubscribe_params=unsubscribe_params, unsubscribe_message=unsubscribe_message,
attachments=attachments, reply_to=reply_to, cc=cc, bcc=bcc, message_id=message_id, in_reply_to=in_reply_to,
send_after=send_after, expose_recipients=expose_recipients, send_priority=send_priority,
send_after=send_after, expose_recipients=expose_recipients, send_priority=send_priority, queue_separately=queue_separately,
communication=communication, now=now, read_receipt=read_receipt, is_notification=is_notification,
inline_images=inline_images, header=header, print_letterhead=print_letterhead, with_container=with_container)

View file

@ -19,9 +19,12 @@
"message",
"message_md",
"message_html",
"section_break_13",
"send_unsubscribe_link",
"send_attachments",
"column_break_9",
"published",
"send_webview_link",
"route",
"test_the_newsletter",
"test_email_id",
@ -160,6 +163,21 @@
"fieldtype": "Check",
"label": "Schedule Sending",
"read_only_depends_on": "eval: doc.email_sent"
},
{
"fieldname": "column_break_9",
"fieldtype": "Column Break"
},
{
"default": "0",
"depends_on": "published",
"fieldname": "send_webview_link",
"fieldtype": "Check",
"label": "Send Web View Link"
},
{
"fieldname": "section_break_13",
"fieldtype": "Section Break"
}
],
"has_web_view": 1,
@ -169,7 +187,7 @@
"is_published_field": "published",
"links": [],
"max_attachments": 3,
"modified": "2020-08-24 19:59:37.262500",
"modified": "2021-02-22 14:33:56.095380",
"modified_by": "Administrator",
"module": "Email",
"name": "Newsletter",

View file

@ -68,13 +68,17 @@ class Newsletter(WebsiteGenerator):
except IOError:
frappe.throw(_("Unable to find attachment {0}").format(file.name))
send(recipients=self.recipients, sender=sender,
subject=self.subject, message=self.get_message(),
args = {
"message": self.get_message(),
"name": self.name
}
frappe.sendmail(recipients=self.recipients, sender=sender,
subject=self.subject, message=self.get_message(), template="newsletter",
reference_doctype=self.doctype, reference_name=self.name,
add_unsubscribe_link=self.send_unsubscribe_link, attachments=attachments,
unsubscribe_method="/unsubscribe",
unsubscribe_params={"name": self.name},
send_priority=0, queue_separately=True)
send_priority=0, queue_separately=True, args=args)
if not frappe.flags.in_test:
frappe.db.auto_commit_on_many_writes = False

View file

@ -0,0 +1,10 @@
<div style="text-align: justify;">
<div style="width: 600px; margin: 10px auto;">
{{ message }}
</div>
</div>
<div style="font-size: 12px; line-height: 20px;">
<div>
Open in <a style="color: #687178; text-decoration: underline;" href="/newsletters/{{ name }}" target="_blank">web</a>
</div>
</div>