From 7cc7319a8aaeafb185f6d5e7d50d8142c34e1a4c Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 7 Aug 2018 14:39:39 +0530 Subject: [PATCH 1/9] DocType name should not have hyphens in it (#5934) --- frappe/core/doctype/doctype/doctype.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index b82b012e23..c6ffba94ae 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -396,9 +396,9 @@ class DocType(Document): # a DocType's name should not start with a number or underscore # and should only contain letters, numbers and underscore if six.PY2: - is_a_valid_name = re.match("^(?![\W])[^\d_\s][\w -]+$", name) + is_a_valid_name = re.match("^(?![\W])[^\d_\s][\w ]+$", name) else: - is_a_valid_name = re.match("^(?![\W])[^\d_\s][\w -]+$", name, flags = re.ASCII) + is_a_valid_name = re.match("^(?![\W])[^\d_\s][\w ]+$", name, flags = re.ASCII) if not is_a_valid_name: frappe.throw(_("DocType's name should start with a letter and it can only consist of letters, numbers, spaces and underscores"), frappe.NameError) From 62a7214a9b25ae7e90f76a1096d8b67b064ac013 Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Tue, 7 Aug 2018 14:43:32 +0530 Subject: [PATCH 2/9] Check if fieldname is present in row else continue (#5912) --- frappe/email/doctype/auto_email_report/auto_email_report.py | 1 + 1 file changed, 1 insertion(+) diff --git a/frappe/email/doctype/auto_email_report/auto_email_report.py b/frappe/email/doctype/auto_email_report/auto_email_report.py index 01b8566982..4942d98375 100644 --- a/frappe/email/doctype/auto_email_report/auto_email_report.py +++ b/frappe/email/doctype/auto_email_report/auto_email_report.py @@ -108,6 +108,7 @@ class AutoEmailReport(Document): new_row = [] out.append(new_row) for df in columns: + if not row.get(df.fieldname): continue new_row.append(frappe.format(row[df.fieldname], df, row)) return out From 0f68fec03e1fea923f57fbb08b8ad6f5d30a345e Mon Sep 17 00:00:00 2001 From: "FinByz Tech Pvt. Ltd" Date: Tue, 7 Aug 2018 14:45:36 +0530 Subject: [PATCH 3/9] Added outgoing sender in email alert (#5892) * Added outgoing sender in email alert * Added semicolon * Minor fix --- .../email/doctype/email_alert/email_alert.js | 10 +++ .../doctype/email_alert/email_alert.json | 64 ++++++++++++++++++- .../email/doctype/email_alert/email_alert.py | 7 ++ 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/frappe/email/doctype/email_alert/email_alert.js b/frappe/email/doctype/email_alert/email_alert.js index 3f7423bc1b..a901b257cb 100755 --- a/frappe/email/doctype/email_alert/email_alert.js +++ b/frappe/email/doctype/email_alert/email_alert.js @@ -1,3 +1,13 @@ +this.frm.add_fetch('sender', 'email_id', 'sender_email'); + +this.frm.fields_dict.sender.get_query = function(){ + return { + filters: { + 'enable_outgoing': 1 + } + } +}; + frappe.email_alert = { setup_fieldname_select: function(frm) { // get the doctype to update fields diff --git a/frappe/email/doctype/email_alert/email_alert.json b/frappe/email/doctype/email_alert/email_alert.json index fd3763cd14..860bfbd46d 100755 --- a/frappe/email/doctype/email_alert/email_alert.json +++ b/frappe/email/doctype/email_alert/email_alert.json @@ -379,6 +379,68 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "sender", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Sender", + "length": 0, + "no_copy": 0, + "options": "Email Account", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "sender_email", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Sender Email", + "length": 0, + "no_copy": 0, + "options": "Email", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -871,7 +933,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-09-26 20:10:00.061780", + "modified": "2018-07-30 14:32:02.179599", "modified_by": "Administrator", "module": "Email", "name": "Email Alert", diff --git a/frappe/email/doctype/email_alert/email_alert.py b/frappe/email/doctype/email_alert/email_alert.py index cfd081d7ae..ac0ef21536 100755 --- a/frappe/email/doctype/email_alert/email_alert.py +++ b/frappe/email/doctype/email_alert/email_alert.py @@ -105,6 +105,7 @@ def get_context(context): def send(self, doc): '''Build recipients and send email alert''' + from email.utils import formataddr def get_attachment(doc): """ check print settings are attach the pdf """ @@ -126,6 +127,7 @@ def get_context(context): context = get_context(doc) recipients = [] + sender = "" for recipient in self.recipients: if recipient.condition: @@ -157,6 +159,10 @@ def get_context(context): context = {"doc": doc, "alert": self, "comments": None} + if self.sender: + sender = formataddr((self.sender, self.sender_email)) + frappe.errprint(sender) + if self.is_standard: self.load_standard_properties(context) @@ -170,6 +176,7 @@ def get_context(context): frappe.sendmail(recipients=recipients, subject=subject, message= frappe.render_template(self.message, context), + sender = sender, reference_doctype = doc.doctype, reference_name = doc.name, attachments = attachments, From 71efb0e8e6e9157dc416619d486adbe92817fe8c Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Tue, 7 Aug 2018 13:02:10 +0000 Subject: [PATCH 4/9] [fix] scrub options of whitespace --- frappe/core/doctype/doctype/doctype.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index b82b012e23..ac603460fc 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -55,6 +55,7 @@ class DocType(Document): self.permissions = [] self.scrub_field_names() + self.scrub_options_in_select() self.set_default_in_list_view() self.validate_series() self.validate_document_type() @@ -177,6 +178,17 @@ class DocType(Document): # fieldnames should be lowercase d.fieldname = d.fieldname.lower() + def scrub_options_in_select(self): + """Strip options for whitespaces""" + for field in self.fields: + if field.fieldtype == "Select" and field.options is not None: + new_options = "" + for option in field.options.split("\n"): + new_options += option.strip() + new_options += "\n" + new_options.rstrip("\n") + field.options = new_options + def validate_series(self, autoname=None, name=None): """Validate if `autoname` property is correctly set.""" if not autoname: autoname = self.autoname From 54238c7e4c7aceb642ad117561c3dffcf5fabdf8 Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Mon, 13 Aug 2018 10:30:21 +0530 Subject: [PATCH 5/9] Fix comment mentions again (#5945) * Fix comment mentions again * Improvise as per suggestion * Show mentions based on emails instead of names --- frappe/core/doctype/communication/comment.py | 2 +- frappe/core/doctype/user/user.py | 2 +- frappe/public/js/frappe/form/footer/timeline.js | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frappe/core/doctype/communication/comment.py b/frappe/core/doctype/communication/comment.py index 2c7a4bd122..0ceb93219c 100644 --- a/frappe/core/doctype/communication/comment.py +++ b/frappe/core/doctype/communication/comment.py @@ -94,7 +94,7 @@ def notify_mentions(doc): subject = _("{0} mentioned you in a comment").format(sender_fullname) - recipients = [frappe.db.get_value("User", {"enabled": 1, "name": name, "user_type": "System User"}) + recipients = [frappe.db.get_value("User", {"enabled": 1, "name": name, "user_type": "System User"}, "email") for name in mentions] frappe.sendmail( recipients=recipients, diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index cb85399fb9..c4378dbb8c 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -901,10 +901,10 @@ def notify_admin_access_to_system_manager(login_manager=None): def extract_mentions(txt): """Find all instances of @name in the string. The mentions will be separated by non-word characters or may appear at the start of the string""" + txt = txt.replace("
", "
") txt = re.sub(r'(<[a-zA-Z\/][^>]*>)', '', txt) return re.findall(r'(?:[^\w\.\-\@]|^)@([\w\.\-\@]*)', txt) - def handle_password_test_fail(result): suggestions = result['feedback']['suggestions'][0] if result['feedback']['suggestions'] else '' warning = result['feedback']['warning'] if 'warning' in result['feedback'] else '' diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js index 7c760b80a3..d93a9ae804 100644 --- a/frappe/public/js/frappe/form/footer/timeline.js +++ b/frappe/public/js/frappe/form/footer/timeline.js @@ -118,7 +118,6 @@ frappe.ui.form.Timeline = Class.extend({ this.wrapper.toggle(true); this.list.empty(); this.comment_area.val(''); - var communications = this.get_communications(true); communications @@ -178,7 +177,6 @@ frappe.ui.form.Timeline = Class.extend({ } else { var $edit_btn = $(this); var content = $timeline_item.find('.timeline-item-content').html(); - $edit_btn .text("Save") .find('i') @@ -298,7 +296,6 @@ frappe.ui.form.Timeline = Class.extend({ c.original_content = c.content; c.content = frappe.utils.toggle_blockquote(c.content); } - if(!frappe.utils.is_html(c.content)) { c.content_html = frappe.markdown(__(c.content)); } else { @@ -312,7 +309,17 @@ frappe.ui.form.Timeline = Class.extend({ // avoid adding tag a 2nd time !c.content_html.match(/(^|\W)(@[^\s]+)<\/b>/) ) { - c.content_html = c.content_html.replace(/(^|\W)(@[^\s]+)/g, "$1$2"); + /* + Replace the email ids by only displaying the string which + occurs before the second `@` to enhance the mentions. + Eg. + @abc@a-example.com will be converted to + @abc with the below line of code. + */ + + c.content_html = c.content_html.replace(/(<[a][^>]*>)/g, ""); + // bold the @mentions + c.content_html = c.content_html.replace(/(@[^\s@]*)@[^\s@|<]*/g, "$1"); } if (this.is_communication_or_comment(c)) { @@ -657,7 +664,7 @@ frappe.ui.form.Timeline = Class.extend({ var valid_users = Object.keys(frappe.boot.user_info) .filter(user => !["Administrator", "Guest"].includes(user)); - return valid_users.map(user => frappe.boot.user_info[user].name); + return valid_users.map(user => frappe.boot.user_info[user].email); }, setup_comment_like: function() { From 89a8073c1f8ea8d48fc6dd577e79c63ff9ba1172 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Wed, 22 Aug 2018 11:00:26 +0530 Subject: [PATCH 6/9] [fix] the patch needs to be executed before reloading moduledef (#5996) --- frappe/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/patches.txt b/frappe/patches.txt index 3c8884b52b..ca22f99fbe 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -8,13 +8,13 @@ frappe.patches.v7_2.remove_in_filter execute:frappe.reload_doc('core', 'doctype', 'doctype', force=True) #2017-09-22 execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2017-03-03 execute:frappe.reload_doc('core', 'doctype', 'docperm') #2017-03-03 +frappe.patches.v8_0.drop_is_custom_from_docperm execute:frappe.reload_doc('core', 'doctype', 'module_def') #2017-09-22 execute:frappe.reload_doc('core', 'doctype', 'version') #2017-04-01 execute:frappe.reload_doc('core', 'doctype', 'activity_log') frappe.patches.v7_1.rename_scheduler_log_to_error_log frappe.patches.v6_1.rename_file_data frappe.patches.v7_0.re_route #2016-06-27 -frappe.patches.v8_0.drop_is_custom_from_docperm frappe.patches.v8_0.update_records_in_global_search #11-05-2017 frappe.patches.v8_0.update_published_in_global_search execute:frappe.reload_doc('core', 'doctype', 'custom_docperm') From 503da4d7d7d3c89ce3169869dd256da4d61b460c Mon Sep 17 00:00:00 2001 From: Shreya Shah Date: Thu, 23 Aug 2018 16:00:43 +0530 Subject: [PATCH 7/9] Modify smallest currency fraction for USD (#6000) --- frappe/geo/country_info.json | 2 +- frappe/patches.txt | 3 ++- frappe/patches/v10_0/modify_smallest_currency_fraction.py | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 frappe/patches/v10_0/modify_smallest_currency_fraction.py diff --git a/frappe/geo/country_info.json b/frappe/geo/country_info.json index f3a251f72d..41b8b3de81 100644 --- a/frappe/geo/country_info.json +++ b/frappe/geo/country_info.json @@ -2554,7 +2554,7 @@ "currency": "USD", "currency_fraction": "Cent", "currency_fraction_units": 100, - "smallest_currency_fraction_value": 0.05, + "smallest_currency_fraction_value": 0.01, "currency_name": "US Dollar", "currency_symbol": "$", "date_format": "mm-dd-yyyy", diff --git a/frappe/patches.txt b/frappe/patches.txt index ca22f99fbe..7025c7fafb 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -203,4 +203,5 @@ execute:frappe.delete_doc('Page', 'data-import-tool', ignore_missing=True) frappe.patches.v10_0.reload_countries_and_currencies frappe.patches.v10_0.set_no_copy_to_workflow_state frappe.patches.v10_0.increase_single_table_column_length -frappe.patches.v10_0.set_default_locking_time \ No newline at end of file +frappe.patches.v10_0.set_default_locking_time +frappe.patches.v10_0.modify_smallest_currency_fraction \ No newline at end of file diff --git a/frappe/patches/v10_0/modify_smallest_currency_fraction.py b/frappe/patches/v10_0/modify_smallest_currency_fraction.py new file mode 100644 index 0000000000..c9ae477359 --- /dev/null +++ b/frappe/patches/v10_0/modify_smallest_currency_fraction.py @@ -0,0 +1,7 @@ +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +import frappe + +def execute(): + frappe.db.set_value('Currency', 'USD', 'smallest_currency_fraction_value', '0.01') \ No newline at end of file From ca1946152d81519bd6a218eb723ff439b54686fa Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Aug 2018 12:45:01 +0530 Subject: [PATCH 8/9] Update email_alert.py --- frappe/email/doctype/email_alert/email_alert.py | 1 - 1 file changed, 1 deletion(-) diff --git a/frappe/email/doctype/email_alert/email_alert.py b/frappe/email/doctype/email_alert/email_alert.py index ac0ef21536..1da959956f 100755 --- a/frappe/email/doctype/email_alert/email_alert.py +++ b/frappe/email/doctype/email_alert/email_alert.py @@ -161,7 +161,6 @@ def get_context(context): if self.sender: sender = formataddr((self.sender, self.sender_email)) - frappe.errprint(sender) if self.is_standard: self.load_standard_properties(context) From 8100327b51a92224dd667c38753e486de9771f1f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Aug 2018 13:16:09 +0600 Subject: [PATCH 9/9] bumped to version 10.1.46 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 9dd5cc427b..bdc8232ea3 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__ = '10.1.45' +__version__ = '10.1.46' __title__ = "Frappe Framework" local = Local()