From 1b99d82856a7b1a5ba3317d32b2281f924a5151c Mon Sep 17 00:00:00 2001 From: mbauskar Date: Mon, 14 Aug 2017 16:34:20 +0530 Subject: [PATCH 01/10] [hotfix] filters with the special characters are escaped twice --- frappe/desk/reportview.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/desk/reportview.py b/frappe/desk/reportview.py index 0ce1d495f8..7c51feb2c7 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], basestring) and f[1][0] == '!': flt.append([doctype, f[0], '!=', f[1][1:]]) else: - value = frappe.db.escape(f[1]) if isinstance(f[1], basestring) else f[1] - flt.append([doctype, f[0], '=', value]) + flt.append([doctype, f[0], '=', f[1]]) query = DatabaseQuery(doctype) query.filters = flt From 67668684ab8e32f0f8fd9de209437f66c127ab0e Mon Sep 17 00:00:00 2001 From: Robert Kirschner Date: Mon, 14 Aug 2017 13:12:30 +0200 Subject: [PATCH 02/10] [minor] fix of translatable terms --- frappe/core/page/desktop/desktop.js | 2 +- frappe/model/delete_doc.py | 2 +- frappe/public/js/frappe/desk.js | 4 ++-- frappe/public/js/frappe/ui/toolbar/awesome_bar.js | 4 ++-- frappe/templates/includes/list/list.html | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) 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/model/delete_doc.py b/frappe/model/delete_doc.py index 3e4f60c7f6..2994b7c9aa 100644 --- a/frappe/model/delete_doc.py +++ b/frappe/model/delete_doc.py @@ -168,7 +168,7 @@ def check_permission_and_not_submitted(doc): # check if submitted if doc.docstatus == 1: - frappe.msgprint(_("{0} {1}: Submitted Record cannot be deleted.").format(doc.doctype, doc.name), + frappe.msgprint(_("{0} {1}: Submitted Record cannot be deleted.").format(_(doc.doctype), doc.name), raise_exception=True) def check_if_doc_is_linked(doc, method="Delete"): diff --git a/frappe/public/js/frappe/desk.js b/frappe/public/js/frappe/desk.js index 2816c755ad..e76ef9105e 100644 --- a/frappe/public/js/frappe/desk.js +++ b/frappe/public/js/frappe/desk.js @@ -92,9 +92,9 @@ frappe.Application = Class.extend({ var dialog = frappe.msgprint({ message:__("The application has been updated to a new version, please refresh this page"), indicator: 'green', - title: 'Version Updated' + title: __('Version Updated') }); - dialog.set_primary_action("Refresh", function() { + dialog.set_primary_action(__("Refresh"), function() { location.reload(true); }); dialog.get_close_btn().toggle(false); diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js index 53ca4cfff0..cd1b743735 100644 --- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js +++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js @@ -229,8 +229,8 @@ frappe.search.AwesomeBar = Class.extend({ var options = {}; options[search_field] = ["like", "%" + txt + "%"]; this.options.push({ - label: __('Find {0} in {1}', [txt.bold(), route[1].bold()]), - value: __('Find {0} in {1}', [txt, route[1]]), + label: __('Find {0} in {1}', [txt.bold(), __(route[1]).bold()]), + value: __('Find {0} in {1}', [txt, __(route[1])]), route_options: options, onclick: function() { cur_list.refresh(); diff --git a/frappe/templates/includes/list/list.html b/frappe/templates/includes/list/list.html index 23f358bdb3..3a1c72fb5d 100644 --- a/frappe/templates/includes/list/list.html +++ b/frappe/templates/includes/list/list.html @@ -20,7 +20,7 @@ {% endfor %}
- +
{%- endif %} From 67e16a58a61a8942cd1eec264f7a07146008d350 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 16 Aug 2017 14:12:48 +0530 Subject: [PATCH 03/10] [fix] unsubscribe link shouldn't append always (#3932) --- frappe/email/queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/email/queue.py b/frappe/email/queue.py index e3e2267f6e..233f7a89a4 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 From 7cd17ffa949c06f52e25c831556511ad137fe5bd Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Wed, 16 Aug 2017 14:52:15 +0530 Subject: [PATCH 04/10] [hotfix] set the file_url on file field on change event (#3934) --- .../js/frappe/form/footer/attachments.js | 67 +++++++++++++------ 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/frappe/public/js/frappe/form/footer/attachments.js b/frappe/public/js/frappe/form/footer/attachments.js index 43c86bb812..67a08813af 100644 --- a/frappe/public/js/frappe/form/footer/attachments.js +++ b/frappe/public/js/frappe/form/footer/attachments.js @@ -211,10 +211,51 @@ frappe.ui.get_upload_dialog = function(opts){ title: __('Upload Attachment'), no_focus: true, fields: [ - {"fieldtype": "Section Break"}, - {"fieldtype": "Link" , "fieldname": "file" , "label": __("Select uploaded file"), "options": "File"}, - {"hidden": !opts.args.doctype || !frappe.boot.gsuite_enabled,"fieldtype": "Section Break", "label": __("GSuite Document")}, - {"fieldtype": "Link" ,"fieldname": "gs_template" ,"label": __("Select template"), "options": "GSuite Templates", reqd : false, filters: {'related_doctype': opts.args.doctype}}, + { + "fieldtype": "Section Break" + }, + { + "fieldtype": "Link" , + "fieldname": "file" , + "label": __("Select uploaded file"), + "options": "File", + onchange: function() { + frappe.call({ + 'method': 'frappe.client.get_value', + 'args': { + 'doctype': 'File', + 'fieldname': ['file_url','file_name','is_private'], + 'filters': { + 'name': dialog.get_value("file") + } + }, + callback: function(r){ + if(!r.message) { + dialog.$wrapper.find('[name="file_url"]').val(""); + return; + } + dialog.$wrapper.find('[name="file_url"]').val(r.message.file_url); + dialog.$wrapper.find('.private-file input').prop('checked', r.message.is_private); + opts.args.filename = r.message.file_name; + } + }); + } + }, + { + "hidden": !opts.args.doctype || !frappe.boot.gsuite_enabled, + "fieldtype": "Section Break", + "label": __("GSuite Document"), + }, + { + "fieldtype": "Link" , + "fieldname": "gs_template" , + "label": __("Select template"), + "options": "GSuite Templates", + "reqd" : false, + "filters": { + 'related_doctype': opts.args.doctype + } + }, ], }); var btn = dialog.set_primary_action(__("Attach")); @@ -229,24 +270,6 @@ frappe.ui.get_upload_dialog = function(opts){ opts.args.gs_template = fd.gs_template.get_value(); }); - $(fd.file.input).change(function() { - frappe.call({ - 'method': 'frappe.client.get_value', - 'args': { - 'doctype': 'File', - 'fieldname': ['file_url','file_name','is_private'], - 'filters': { - 'name': dialog.get_value("file") - } - }, - callback: function(r){ - if(!r.message) return; - dialog.$wrapper.find('[name="file_url"]').val(r.message.file_url); - dialog.$wrapper.find('.private-file input').prop('checked', r.message.is_private); - opts.args.filename = r.message.file_name; - } - }); - }); frappe.upload.make({ parent: upload_area, args: opts.args, From 73aa0a35c48a0d25027ce6432da023d4216b0bbc Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 16 Aug 2017 15:50:20 +0530 Subject: [PATCH 05/10] Patch old event colors to hex --- frappe/patches.txt | 1 + frappe/patches/v8_5/patch_event_colors.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 frappe/patches/v8_5/patch_event_colors.py diff --git a/frappe/patches.txt b/frappe/patches.txt index 3347ae8287..a9a28d5f05 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -190,3 +190,4 @@ frappe.patches.v8_1.update_format_options_in_auto_email_report frappe.patches.v8_1.delete_custom_docperm_if_doctype_not_exists frappe.patches.v8_5.delete_email_group_member_with_invalid_emails frappe.patches.v8_x.update_user_permission +frappe.patches.v8_5.patch_event_colors diff --git a/frappe/patches/v8_5/patch_event_colors.py b/frappe/patches/v8_5/patch_event_colors.py new file mode 100644 index 0000000000..189f2a8f3f --- /dev/null +++ b/frappe/patches/v8_5/patch_event_colors.py @@ -0,0 +1,21 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + colors = ['red', 'green', 'blue', 'yellow', 'skyblue', 'orange'] + hex = ['#ffc4c4', '#cef6d1', '#d2d2ff', '#fffacd', '#d2f1ff', '#ffd2c2'] + + def get_hex_for_color(color): + index = colors.index(color) + return hex[index] + + query = ''' + update tabEvent + set color='{hex}' + where color='{color}' + ''' + + for color in colors: + frappe.db.sql(query.format(color=color, hex=get_hex_for_color(color))) + + frappe.db.commit() \ No newline at end of file From 702dd1b73ac6f80cb7e24242739e6c6f778d1486 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 16 Aug 2017 16:02:57 +0530 Subject: [PATCH 06/10] codacy fix --- frappe/patches/v8_5/patch_event_colors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frappe/patches/v8_5/patch_event_colors.py b/frappe/patches/v8_5/patch_event_colors.py index 189f2a8f3f..7a48b6c3e2 100644 --- a/frappe/patches/v8_5/patch_event_colors.py +++ b/frappe/patches/v8_5/patch_event_colors.py @@ -3,11 +3,11 @@ import frappe def execute(): colors = ['red', 'green', 'blue', 'yellow', 'skyblue', 'orange'] - hex = ['#ffc4c4', '#cef6d1', '#d2d2ff', '#fffacd', '#d2f1ff', '#ffd2c2'] + hex_colors = ['#ffc4c4', '#cef6d1', '#d2d2ff', '#fffacd', '#d2f1ff', '#ffd2c2'] def get_hex_for_color(color): index = colors.index(color) - return hex[index] + return hex_colors[index] query = ''' update tabEvent @@ -18,4 +18,4 @@ def execute(): for color in colors: frappe.db.sql(query.format(color=color, hex=get_hex_for_color(color))) - frappe.db.commit() \ No newline at end of file + frappe.db.commit() From ce8f76ff4a815b77f645fa1d27a74cc735e56022 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Wed, 16 Aug 2017 16:15:26 +0530 Subject: [PATCH 07/10] [hotfix] check daily email limit before sending emails --- frappe/email/queue.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frappe/email/queue.py b/frappe/email/queue.py index e3e2267f6e..5aa6e4c802 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -218,9 +218,17 @@ 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 + + # get count of today's sent mails + today = get_emails_sent_today() + if daily_email_limit and (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 +244,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 DATE(creation)=CURDATE()""")[0][0] + def get_unsubscribe_message(unsubscribe_message, expose_recipients): if unsubscribe_message: unsubscribe_html = ''' Date: Wed, 16 Aug 2017 16:42:50 +0530 Subject: [PATCH 08/10] [hotfix] minor fixes --- frappe/email/queue.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frappe/email/queue.py b/frappe/email/queue.py index 5aa6e4c802..67c1f1d739 100755 --- a/frappe/email/queue.py +++ b/frappe/email/queue.py @@ -224,11 +224,12 @@ def check_email_limit(recipients): monthly_email_limit = 500 daily_email_limit = 50 - # get count of today's sent mails - today = get_emails_sent_today() - if daily_email_limit and (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 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 @@ -246,7 +247,7 @@ def get_emails_sent_this_month(): def get_emails_sent_today(): return frappe.db.sql("""select count(name) from `tabEmail Queue` where - status='Sent' and DATE(creation)=CURDATE()""")[0][0] + status='Sent' and creation>DATE_SUB(NOW(), INTERVAL 24 HOUR)""")[0][0] def get_unsubscribe_message(unsubscribe_message, expose_recipients): if unsubscribe_message: From 91d87814ca3e86a4b840baaba7567e65f4ca5d46 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Wed, 16 Aug 2017 18:14:20 +0530 Subject: [PATCH 09/10] [hotfix] add daily_emails limit to set-limit command (#3939) --- frappe/commands/site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 3716a0b0bd..fafbb25fc5 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)) From 9f277db145c97a44875ca404d4f1e34c186572fb Mon Sep 17 00:00:00 2001 From: mbauskar Date: Wed, 16 Aug 2017 18:47:28 +0600 Subject: [PATCH 10/10] bumped to version 8.7.6 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 0666bba88b..befcfee04e 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()