Selaa lähdekoodia

Merge pull request #1868 from vjFaLk/email-group-fix

Email Group fixes
version-14
Anand Doshi 9 vuotta sitten
committed by GitHub
vanhempi
commit
45c8e6369e
2 muutettua tiedostoa jossa 11 lisäystä ja 5 poistoa
  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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 = {


Ladataan…
Peruuta
Tallenna