Selaa lähdekoodia

[minor] added reply-to in frappe.sendmail and cleanup

version-14
Rushabh Mehta 10 vuotta sitten
vanhempi
commit
8bf7d1ded8
11 muutettua tiedostoa jossa 32 lisäystä ja 31 poistoa
  1. +6
    -4
      frappe/__init__.py
  2. +2
    -6
      frappe/desk/doctype/event/event.py
  3. +3
    -3
      frappe/desk/doctype/todo/todo.json
  4. +2
    -3
      frappe/desk/page/messages/messages.py
  5. +4
    -4
      frappe/email/__init__.py
  6. +4
    -4
      frappe/email/bulk.py
  7. +2
    -2
      frappe/email/doctype/bulk_email/bulk_email.json
  8. +2
    -2
      frappe/email/doctype/email_account/email_account.py
  9. +2
    -1
      frappe/email/email_body.py
  10. +1
    -2
      frappe/tasks.py
  11. +4
    -0
      frappe/utils/user.py

+ 6
- 4
frappe/__init__.py Näytä tiedosto

@@ -268,7 +268,7 @@ def get_request_header(key, default=None):

def sendmail(recipients=(), sender="", subject="No Subject", message="No Message",
as_markdown=False, bulk=False, ref_doctype=None, ref_docname=None,
add_unsubscribe_link=False, attachments=None, content=None, doctype=None, name=None):
add_unsubscribe_link=False, attachments=None, content=None, doctype=None, name=None, reply_to=None):
"""Send email using user's default **Email Account** or global default **Email Account**.


@@ -282,22 +282,24 @@ def sendmail(recipients=(), sender="", subject="No Subject", message="No Message
:param ref_docname: (or `name`) Append as communication to this document name.
:param add_unsubscribe_link: Allow user to unsubscribe from these emails.
:param attachments: List of attachments.
:param reply_to: Reply-To email id.
"""

if bulk:
import frappe.email.bulk
frappe.email.bulk.send(recipients=recipients, sender=sender,
subject=subject, message=content or message, ref_doctype = doctype or ref_doctype,
ref_docname = name or ref_docname, add_unsubscribe_link=add_unsubscribe_link, attachments=attachments)
ref_docname = name or ref_docname, add_unsubscribe_link=add_unsubscribe_link, attachments=attachments,
reply_to=reply_to)

else:
import frappe.email
if as_markdown:
frappe.email.sendmail_md(recipients, sender=sender,
subject=subject, msg=content or message, attachments=attachments)
subject=subject, msg=content or message, attachments=attachments, reply_to=reply_to)
else:
frappe.email.sendmail(recipients, sender=sender,
subject=subject, msg=content or message, attachments=attachments)
subject=subject, msg=content or message, attachments=attachments, reply_to=reply_to)

logger = None
whitelisted = []


+ 2
- 6
frappe/desk/doctype/event/event.py Näytä tiedosto

@@ -5,8 +5,8 @@ from __future__ import unicode_literals
import frappe

from frappe.utils import getdate, cint, add_months, date_diff, add_days, nowdate
from frappe.core.doctype.user.user import STANDARD_USERS
from frappe.model.document import Document
from frappe.utils.user import get_enabled_system_users

weekdays = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]

@@ -46,11 +46,7 @@ def has_permission(doc, user):

def send_event_digest():
today = nowdate()
for user in frappe.db.sql("""select name, email, language
from tabUser where ifnull(enabled,0)=1
and user_type='System User' and name not in ({})""".format(", ".join(["%s"]*len(STANDARD_USERS))),
STANDARD_USERS, as_dict=1):

for user in get_enabled_system_users():
events = get_events(today, today, user.name, for_reminder=True)
if events:
text = ""


+ 3
- 3
frappe/desk/doctype/todo/todo.json Näytä tiedosto

@@ -52,7 +52,7 @@
"fieldtype": "Select",
"hidden": 0,
"in_filter": 0,
"in_list_view": 1,
"in_list_view": 0,
"label": "Priority",
"no_copy": 0,
"oldfieldname": "priority",
@@ -70,7 +70,7 @@
"fieldtype": "Date",
"hidden": 0,
"in_filter": 0,
"in_list_view": 1,
"in_list_view": 0,
"label": "Due Date",
"no_copy": 0,
"oldfieldname": "date",
@@ -170,7 +170,7 @@
"in_dialog": 0,
"issingle": 0,
"max_attachments": 0,
"modified": "2015-01-07 10:56:03.251872",
"modified": "2015-01-22 17:54:50.026008",
"modified_by": "Administrator",
"module": "Desk",
"name": "ToDo",


+ 2
- 3
frappe/desk/page/messages/messages.py Näytä tiedosto

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe
from frappe.desk.notifications import delete_notification_count_for
from frappe.core.doctype.user.user import STANDARD_USERS
from frappe.utils.user import get_enabled_system_users
from frappe.utils import cint

@frappe.whitelist()
@@ -83,9 +84,7 @@ def post(txt, contact, parenttype=None, notify=False, subject=None):

if notify and cint(notify):
if contact==frappe.session.user:
_notify([user.name for user in frappe.get_list("User",
{"user_type":"System User", "enabled": 1}) \
if user.name not in ("Guest", "Administrator")], txt)
_notify([user.name for user in get_enabled_system_users()], txt)
else:
_notify(contact, txt, subject)



+ 4
- 4
frappe/email/__init__.py Näytä tiedosto

@@ -7,14 +7,14 @@ import frappe
from frappe.email.email_body import get_email
from frappe.email.smtp import send

def sendmail_md(recipients, sender=None, msg=None, subject=None, attachments=None, content=None):
def sendmail_md(recipients, sender=None, msg=None, subject=None, attachments=None, content=None, reply_to=None):
"""send markdown email"""
import markdown2
sendmail(recipients, sender, markdown2.markdown(content or msg), subject, attachments)
sendmail(recipients, sender, markdown2.markdown(content or msg), subject, attachments, reply_to=reply_to)

def sendmail(recipients, sender='', msg='', subject='[No Subject]', attachments=None, content=None):
def sendmail(recipients, sender='', msg='', subject='[No Subject]', attachments=None, content=None, reply_to=None):
"""send an html email as multipart with attachments and all"""
send(get_email(recipients, sender, content or msg, subject, attachments=attachments))
send(get_email(recipients, sender, content or msg, subject, attachments=attachments, reply_to=reply_to))

def sendmail_to_system_managers(subject, content):
send(get_email(get_system_managers(), None, content, subject))


+ 4
- 4
frappe/email/bulk.py Näytä tiedosto

@@ -15,7 +15,7 @@ class BulkLimitCrossedError(frappe.ValidationError): pass

def send(recipients=None, sender=None, doctype='User', email_field='email',
subject='[No Subject]', message='[No Content]', ref_doctype=None,
ref_docname=None, add_unsubscribe_link=True, attachments=None):
ref_docname=None, add_unsubscribe_link=True, attachments=None, reply_to=None):

def is_unsubscribed(rdata):
if not rdata:
@@ -79,17 +79,17 @@ def send(recipients=None, sender=None, doctype='User', email_field='email',
except HTMLParser.HTMLParseError:
text_content = "[See html attachment]"

add(r, sender, subject, updated, text_content, ref_doctype, ref_docname, attachments)
add(r, sender, subject, updated, text_content, ref_doctype, ref_docname, attachments, reply_to)

def add(email, sender, subject, formatted, text_content=None,
ref_doctype=None, ref_docname=None, attachments=None):
ref_doctype=None, ref_docname=None, attachments=None, reply_to=None):
"""add to bulk mail queue"""
e = frappe.new_doc('Bulk Email')
e.sender = sender
e.recipient = email
try:
e.message = get_email(email, sender=e.sender, formatted=formatted, subject=subject,
text_content=text_content, attachments=attachments).as_string()
text_content=text_content, attachments=attachments, reply_to=reply_to).as_string()
except frappe.InvalidEmailAddressError:
# bad email id - don't add to queue
return


+ 2
- 2
frappe/email/doctype/bulk_email/bulk_email.json Näytä tiedosto

@@ -22,7 +22,7 @@
},
{
"fieldname": "message",
"fieldtype": "Long Text",
"fieldtype": "Code",
"in_list_view": 0,
"label": "Message",
"permlevel": 0
@@ -64,7 +64,7 @@
"icon": "icon-envelope",
"idx": 1,
"in_create": 1,
"modified": "2015-01-21 14:41:14.336182",
"modified": "2015-01-23 04:32:39.175147",
"modified_by": "Administrator",
"module": "Email",
"name": "Bulk Email",


+ 2
- 2
frappe/email/doctype/email_account/email_account.py Näytä tiedosto

@@ -189,5 +189,5 @@ def pull():
"""Will be called via scheduler, pull emails from all enabled POP3 email accounts."""
import frappe.tasks
for email_account in frappe.get_list("Email Account", filters={"enable_incoming": 1}):
#frappe.tasks.pull_from_email_account.delay(frappe.local.site, email_account.name)
frappe.tasks.pull_from_email_account(frappe.local.site, email_account.name)
frappe.tasks.pull_from_email_account.delay(frappe.local.site, email_account.name)
#frappe.tasks.pull_from_email_account(frappe.local.site, email_account.name)

+ 2
- 1
frappe/email/email_body.py Näytä tiedosto

@@ -171,7 +171,8 @@ class EMail:
return email

if not self.sender:
self.sender = get_outgoing_email_account().email_id
email_account = get_outgoing_email_account()
self.sender = "{0} <{1}>".format(email_account.name, email_account.email_id)

self.sender = _validate(self.sender)
self.reply_to = _validate(self.reply_to)


+ 1
- 2
frappe/tasks.py Näytä tiedosto

@@ -118,5 +118,4 @@ def pull_from_email_account(site, email_account):
email_account.receive()
frappe.db.commit()
finally:
pass
#frappe.destroy()
frappe.destroy()

+ 4
- 0
frappe/utils/user.py Näytä tiedosto

@@ -225,3 +225,7 @@ def get_roles(user=None, with_standard=True):
roles = filter(lambda x: x not in ['All', 'Guest', 'Administrator'], roles)

return roles

def get_enabled_system_users():
return frappe.db.sql("""select * from tabUser where
user_type='System User' and enabled=1 and name not in ('Administrator', 'Guest')""", as_dict=1)

Ladataan…
Peruuta
Tallenna