diff --git a/frappe/__init__.py b/frappe/__init__.py index 194b6e4c12..a0d25c2df9 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template -__version__ = '8.7.5' +__version__ = '8.7.6' __title__ = "Frappe Framework" local = Local() diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 6dc8c13311..f8efd4182a 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -447,7 +447,7 @@ def _set_limits(context, site, limits): frappe.connect() new_limits = {} for limit, value in limits: - if limit not in ('emails', 'space', 'users', 'email_group', + if limit not in ('daily_emails', 'emails', 'space', 'users', 'email_group', 'expiry', 'support_email', 'support_chat', 'upgrade_url'): frappe.throw(_('Invalid limit {0}').format(limit)) diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js index ad706f6c18..909f3c70fd 100644 --- a/frappe/core/page/desktop/desktop.js +++ b/frappe/core/page/desktop/desktop.js @@ -27,7 +27,7 @@ $.extend(frappe.desktop, { render: function() { var me = this; - frappe.utils.set_title("Desktop"); + frappe.utils.set_title(__("Desktop")); var template = frappe.list_desktop ? "desktop_list_view" : "desktop_icon_grid"; diff --git a/frappe/desk/reportview.py b/frappe/desk/reportview.py index 9474f6b7e8..ab71fffac1 100644 --- a/frappe/desk/reportview.py +++ b/frappe/desk/reportview.py @@ -353,8 +353,7 @@ def get_filters_cond(doctype, filters, conditions, ignore_permissions=None, with if isinstance(f[1], string_types) and f[1][0] == '!': flt.append([doctype, f[0], '!=', f[1][1:]]) else: - value = frappe.db.escape(f[1]) if isinstance(f[1], string_types) else f[1] - flt.append([doctype, f[0], '=', value]) + flt.append([doctype, f[0], '=', f[1]]) query = DatabaseQuery(doctype) query.filters = flt diff --git a/frappe/email/queue.py b/frappe/email/queue.py index 975e36f23f..3260a0efdf 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -95,7 +95,7 @@ def send(recipients=None, sender=None, subject=None, message=None, text_content= and add_unsubscribe_link==1) unsubscribe_link = None - if should_append_unsubscribe or True: + if should_append_unsubscribe: unsubscribe_link = get_unsubscribe_message(unsubscribe_message, expose_recipients) email_text_context += unsubscribe_link.text @@ -218,9 +218,18 @@ def check_email_limit(recipients): or frappe.flags.in_test): monthly_email_limit = frappe.conf.get('limits', {}).get('emails') + daily_email_limit = frappe.conf.get('limits', {}).get('daily_emails') if frappe.flags.in_test: monthly_email_limit = 500 + daily_email_limit = 50 + + if daily_email_limit: + # get count of sent mails in last 24 hours + today = get_emails_sent_today() + if (today + len(recipients)) > daily_email_limit: + throw(_("Cannot send this email. You have crossed the sending limit of {0} emails for this day.").format(daily_email_limit), + EmailLimitCrossedError) if not monthly_email_limit: return @@ -236,6 +245,10 @@ def get_emails_sent_this_month(): return frappe.db.sql("""select count(name) from `tabEmail Queue` where status='Sent' and MONTH(creation)=MONTH(CURDATE())""")[0][0] +def get_emails_sent_today(): + return frappe.db.sql("""select count(name) from `tabEmail Queue` where + status='Sent' and creation>DATE_SUB(NOW(), INTERVAL 24 HOUR)""")[0][0] + def get_unsubscribe_message(unsubscribe_message, expose_recipients): if unsubscribe_message: unsubscribe_html = '''