Valmik Jangla 9 лет назад
Родитель
Сommit
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
import frappe
from frappe import _
from frappe.utils import validate_email_add
from frappe.model.document import Document
from email.utils import parseaddr

class EmailGroup(Document):
def onload(self):
@@ -90,10 +93,10 @@ def add_subscribers(name, email_list):
def restrict_email_group(doc, method):
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:
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))

+ 5
- 2
frappe/hooks.py Просмотреть файл

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

}

scheduler_events = {


Загрузка…
Отмена
Сохранить