Rushabh Mehta 11 anni fa
parent
commit
347b03f8a6
5 ha cambiato i file con 23 aggiunte e 21 eliminazioni
  1. +0
    -2
      frappe/boot.py
  2. +13
    -10
      frappe/core/doctype/communication/communication.py
  3. +1
    -9
      frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json
  4. +8
    -0
      frappe/utils/email_lib/email_body.py
  5. +1
    -0
      requirements.txt

+ 0
- 2
frappe/boot.py Vedi File

@@ -24,8 +24,6 @@ def get_bootinfo():
# system info
bootinfo['sysdefaults'] = frappe.defaults.get_defaults()
bootinfo['server_date'] = frappe.utils.nowdate()
bootinfo["send_print_in_body_and_attachment"] = frappe.db.get_value("Outgoing Email Settings",
None, "send_print_in_body_and_attachment")

if frappe.session['user'] != 'Guest':
bootinfo['user_info'] = get_fullnames()


+ 13
- 10
frappe/core/doctype/communication/communication.py Vedi File

@@ -118,21 +118,24 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s
if hasattr(sent_via, "get_content"):
d.content = sent_via.get_content(d)

footer = set_portal_link(sent_via, d)

send_print_in_body = frappe.db.get_value("Outgoing Email Settings", None, "send_print_in_body_and_attachment")
if print_html and not send_print_in_body:
d.content += "<p>Please see attachment for document details.</p>"
footer = "<hr>" + set_portal_link(sent_via, d)
footer += "<p style='color: #888;'>" + _("Please see attachment") + "</p>"

mail = get_email(d.recipients, sender=d.sender, subject=d.subject,
msg=d.content, footer=footer, print_html=print_html if send_print_in_body else None)
msg=d.content, footer=footer)

if send_me_a_copy:
mail.cc.append(frappe.db.get_value("User", frappe.session.user, "email"))

if print_html:
print_html = scrub_urls(print_html)
mail.add_attachment(name.replace(' ','').replace('/','-') + '.html', print_html)

try:
mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html)
except Exception:
frappe.msgprint(_("Error generating PDF, attachment sent as HTML"))
mail.add_attachment(name.replace(' ','').replace('/','-') + '.html',
print_html, 'text/html')

for a in json.loads(attachments):
try:
@@ -145,7 +148,7 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s
def set_portal_link(sent_via, comm):
"""set portal link in footer"""

footer = None
footer = ""

if is_signup_enabled() and hasattr(sent_via, "get_portal_page"):
portal_page = sent_via.get_portal_page()
@@ -154,7 +157,7 @@ def set_portal_link(sent_via, comm):
sent_via.get("contact_email")) in comm.recipients
if is_valid_recipient:
url = "%s/%s?name=%s" % (get_url(), portal_page, urllib.quote(sent_via.name))
footer = """<!-- Portal Link --><hr>
<a href="%s" target="_blank">View this on our website</a>""" % url
footer = """<!-- Portal Link -->
<p><a href="%s" target="_blank">View this on our website</a></p>""" % url

return footer

+ 1
- 9
frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.json Vedi File

@@ -74,14 +74,6 @@
"label": "Auto Email Id",
"permlevel": 0
},
{
"default": "1",
"description": "If checked, an email with an attached HTML format will be added to part of the EMail body as well as attachment. To only send as attachment, uncheck this.",
"fieldname": "send_print_in_body_and_attachment",
"fieldtype": "Check",
"label": "Send Print in Body and Attachment",
"permlevel": 0
},
{
"fieldname": "section_break_10",
"fieldtype": "Section Break",
@@ -100,7 +92,7 @@
"idx": 1,
"in_create": 1,
"issingle": 1,
"modified": "2014-07-04 04:19:14.935886",
"modified": "2014-07-07 11:42:10.128767",
"modified_by": "Administrator",
"module": "Core",
"name": "Outgoing Email Settings",


+ 8
- 0
frappe/utils/email_lib/email_body.py Vedi File

@@ -146,6 +146,14 @@ class EMail:

self.msg_root.attach(part)

def add_pdf_attachment(self, name, html):
import pdfkit, os
fname = frappe.generate_hash() + ".pdf"
pdfkit.from_string(html, fname)
with open(fname, "rb") as fileobj:
self.add_attachment(name, fileobj.read(), 'application/octet-stream')
os.remove(fname)

def validate(self):
"""validate the email ids"""
from frappe.utils import validate_email_add


+ 1
- 0
requirements.txt Vedi File

@@ -21,3 +21,4 @@ requests==1.2.3
celery
redis
selenium
pdfkit

Caricamento…
Annulla
Salva