浏览代码

Email Group fixes

version-14
Valmik Jangla 9 年前
父节点
当前提交
4bdf8fab62
共有 2 个文件被更改,包括 11 次插入5 次删除
  1. +6
    -3
      frappe/email/doctype/email_group/email_group.py
  2. +5
    -2
      frappe/hooks.py

+ 6
- 3
frappe/email/doctype/email_group/email_group.py 查看文件

@@ -4,7 +4,10 @@


from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.utils import validate_email_add
from frappe.model.document import Document from frappe.model.document import Document
from email.utils import parseaddr


class EmailGroup(Document): class EmailGroup(Document):
def onload(self): def onload(self):
@@ -90,10 +93,10 @@ def add_subscribers(name, email_list):
def restrict_email_group(doc, method): def restrict_email_group(doc, method):
from frappe.limits import get_limits from frappe.limits import get_limits


email_group_limit = get_limits().get('newsletter_recipients')
email_group_limit = get_limits().get('email_group_limit')
if not email_group_limit: if not email_group_limit:
return return


nl = frappe.get_doc("Email Group", doc.email_group)
if nl.get_total_subscribers() >= email_group_limit:
email_group = frappe.get_doc("Email Group", doc.email_group)
if email_group.get_total_subscribers() >= email_group_limit:
frappe.throw(_("Please Upgrade to add more than {0} subscribers").format(email_group_limit)) frappe.throw(_("Please Upgrade to add more than {0} subscribers").format(email_group_limit))

+ 5
- 2
frappe/hooks.py 查看文件

@@ -99,7 +99,6 @@ doc_events = {
"after_insert": "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts", "after_insert": "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts",
"validate": [ "validate": [
"frappe.email.doctype.email_alert.email_alert.trigger_email_alerts", "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts",
"frappe.email.doctype.email_group.email_group.restrict_email_group"
], ],
"on_update": [ "on_update": [
"frappe.desk.notifications.clear_doctype_notifications", "frappe.desk.notifications.clear_doctype_notifications",
@@ -115,7 +114,11 @@ doc_events = {
"frappe.email.doctype.email_alert.email_alert.trigger_email_alerts" "frappe.email.doctype.email_alert.email_alert.trigger_email_alerts"
], ],
"on_trash": "frappe.desk.notifications.clear_doctype_notifications" "on_trash": "frappe.desk.notifications.clear_doctype_notifications"
}
},
"Email Group Member": {
"validate": "frappe.email.doctype.email_group.email_group.restrict_email_group"
},

} }


scheduler_events = { scheduler_events = {


正在加载...
取消
保存