diff --git a/frappe/__init__.py b/frappe/__init__.py index fdfcf56a14..18122677b8 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template -__version__ = '7.1.13' +__version__ = '7.1.14' __title__ = "Frappe Framework" local = Local() diff --git a/frappe/client.py b/frappe/client.py index 81bec3787c..52799e4f85 100644 --- a/frappe/client.py +++ b/frappe/client.py @@ -61,7 +61,10 @@ def set_value(doctype, name, fieldname, value=None): if not value: values = fieldname if isinstance(fieldname, basestring): - values = json.loads(fieldname) + try: + values = json.loads(fieldname) + except ValueError: + values = {fieldname: ''} else: values = {fieldname: value} diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 6f538eda8d..d2e9220630 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -22,7 +22,7 @@ def new_site(site, mariadb_root_username=None, mariadb_root_password=None, admin "Create a new site" frappe.init(site=site, new_site=True) - _new_site(None, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, + _new_site(db_name, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, verbose=verbose, install_apps=install_app, source_sql=source_sql, force=force) if len(frappe.utils.get_sites()) == 1: diff --git a/frappe/core/doctype/communication/comment.py b/frappe/core/doctype/communication/comment.py index d78ca3b612..12c31a3e6b 100644 --- a/frappe/core/doctype/communication/comment.py +++ b/frappe/core/doctype/communication/comment.py @@ -11,14 +11,6 @@ from frappe.website.render import clear_cache from frappe.model.db_schema import add_column from frappe.exceptions import ImplicitCommitError -def validate_comment(doc): - """Raise exception for more than 50 comments.""" - if not (doc.communication_type=='Comment' and doc.reference_doctype and doc.reference_name): - return - - if doc.comment_type=="Comment" and "" not in doc.content: - doc.content += '\n' - def on_trash(doc): if doc.communication_type != "Comment": return diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index 74267674cb..9e34dbb876 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -6,8 +6,8 @@ import frappe from frappe import _ from frappe.model.document import Document from frappe.utils import validate_email_add, get_fullname, strip_html, cstr -from frappe.core.doctype.communication.comment import (validate_comment, - notify_mentions, update_comment_in_doc) +from frappe.core.doctype.communication.comment import (notify_mentions, + update_comment_in_doc) from frappe.core.doctype.communication.email import (validate_email, notify, _notify, update_parent_status) from frappe.utils.bot import BotReply @@ -43,7 +43,6 @@ class Communication(Document): self.set_status() self.set_sender_full_name() validate_email(self) - validate_comment(self) self.set_timeline_doc() def after_insert(self): diff --git a/frappe/desk/doctype/desktop_icon/desktop_icon.py b/frappe/desk/doctype/desktop_icon/desktop_icon.py index 30bab229bc..e8170074e6 100644 --- a/frappe/desk/doctype/desktop_icon/desktop_icon.py +++ b/frappe/desk/doctype/desktop_icon/desktop_icon.py @@ -170,7 +170,7 @@ def set_order(new_order, user=None): clear_desktop_icons_cache() -def set_desktop_icons(visible_list): +def set_desktop_icons(visible_list, ignore_duplicate=True): '''Resets all lists and makes only the given one standard, if the desktop icon does not exist and the name is a DocType, then will create an icon for the doctype''' @@ -188,7 +188,11 @@ def set_desktop_icons(visible_list): frappe.db.set_value('Desktop Icon', name, 'hidden', 0) else: if frappe.db.exists('DocType', module_name): - add_user_icon(module_name, standard=1) + try: + add_user_icon(module_name, standard=1) + except frappe.UniqueValidationError, e: + if not ignore_duplicate: + raise e # set the order set_order(visible_list) 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 3a764bf1c1..39c0715473 100644 --- a/frappe/email/doctype/auto_email_report/auto_email_report.py +++ b/frappe/email/doctype/auto_email_report/auto_email_report.py @@ -130,7 +130,7 @@ def send_daily(): # if not correct weekday, skip if auto_email_report.frequency=='Weekly': if now.weekday()!={'Monday':0,'Tuesday':1,'Wednesday':2, - 'Thursday':3,'Friday':4,'Saturday':5,'Sunday':6}[auto_email_report.weekday]: + 'Thursday':3,'Friday':4,'Saturday':5,'Sunday':6}[auto_email_report.day_of_week]: continue auto_email_report.send() diff --git a/frappe/model/document.py b/frappe/model/document.py index e2848af553..b582b7f3ae 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -382,6 +382,7 @@ class Document(BaseDocument): self._validate_selects() self._validate_constants() self._validate_length() + self._extract_images_from_text_editor() self._sanitize_content() self._save_passwords() @@ -390,6 +391,7 @@ class Document(BaseDocument): d._validate_selects() d._validate_constants() d._validate_length() + d._extract_images_from_text_editor() d._sanitize_content() d._save_passwords() @@ -398,11 +400,6 @@ class Document(BaseDocument): for fieldname in optional_fields: self.set(fieldname, None) - # extract images after validations to save processing if some validation error is raised - self._extract_images_from_text_editor() - for d in children: - d._extract_images_from_text_editor() - def apply_fieldlevel_read_permissions(self): '''Remove values the user is not allowed to read (called when loading in desk)''' has_higher_permlevel = False diff --git a/frappe/patches/v7_1/setup_integration_services.py b/frappe/patches/v7_1/setup_integration_services.py index 74df5ee882..0995b1c52c 100644 --- a/frappe/patches/v7_1/setup_integration_services.py +++ b/frappe/patches/v7_1/setup_integration_services.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import frappe from frappe.exceptions import DataError from frappe.utils.password import get_decrypted_password +from frappe.utils import cstr app_list = [ {"app_name": "razorpay_integration", "service_name": "Razorpay", "doctype": "Razorpay Settings", "remove": True}, @@ -55,7 +56,7 @@ def get_app_settings(app_details): for d in controller.fields: if settings.get(d.fieldname): - if ''.join(set(settings.get(d.fieldname))) == '*': + if ''.join(set(cstr(settings.get(d.fieldname)))) == '*': setattr(settings, d.fieldname, get_decrypted_password(doctype, docname, d.fieldname, raise_exception=True)) parameters.update({d.fieldname : settings.get(d.fieldname)}) @@ -85,6 +86,9 @@ def get_parameters(app_details): elif app_details["service_name"] == "Dropbox": doc = frappe.db.get_value(app_details["doctype"], None, ["dropbox_access_key", "dropbox_access_secret", "upload_backups_to_dropbox"], as_dict=1) + + if not doc: + return if not (frappe.conf.dropbox_access_key and frappe.conf.dropbox_secret_key): return diff --git a/frappe/print/page/print_format_builder/print_format_builder.js b/frappe/print/page/print_format_builder/print_format_builder.js index 998f643f67..0feb21bfac 100644 --- a/frappe/print/page/print_format_builder/print_format_builder.js +++ b/frappe/print/page/print_format_builder/print_format_builder.js @@ -89,8 +89,7 @@ frappe.PrintFormatBuilder = Class.extend({ var name = me.print_format_input.get_value(); if(!name) return; frappe.model.with_doc("Print Format", name, function(doc) { - me.print_format = frappe.get_doc("Print Format", name); - me.refresh(); + frappe.set_route('print-format-builder', name); }); }); }, @@ -446,9 +445,9 @@ frappe.PrintFormatBuilder = Class.extend({ }, ], }); - + d.set_value('label', field.attr("data-label")); - + d.set_primary_action(__("Update"), function() { field.attr('data-align', d.get_value('align')); field.attr('data-label', d.get_value('label')); @@ -627,7 +626,7 @@ frappe.PrintFormatBuilder = Class.extend({ return $.map(f.visible_columns, function(v) { return v.fieldname + "|" + (v.print_width || "") }).join(","); }, get_no_content: function() { - return '
'+__("Edit to add content")+'
' + return __("Edit to add content") }, setup_edit_custom_html: function() { var me = this; @@ -637,12 +636,13 @@ frappe.PrintFormatBuilder = Class.extend({ }); }, get_edit_html_dialog: function(title, label, $content) { + var me = this; var d = new frappe.ui.Dialog({ title: title, fields: [ { fieldname: "content", - fieldtype: "Text Editor", + fieldtype: "Code", label: label }, { @@ -657,11 +657,12 @@ frappe.PrintFormatBuilder = Class.extend({ }); // set existing content in input - content = $content.html(); - if(content.indexOf("data-no-content")!==-1) content = ""; + content = $content.attr('data-html-content'); + if(content.indexOf(me.get_no_content())!==-1) content = ""; d.set_input("content", content); d.set_primary_action(__("Update"), function() { + $content.attr('data-html-content', d.get_value("content")); $content.html(d.get_value("content")); d.hide(); }); @@ -696,11 +697,11 @@ frappe.PrintFormatBuilder = Class.extend({ fieldname: $this.attr("data-fieldname"), print_hide: 0 }; - + if(align) { df.align = align; } - + if(label) { df.label = label; } @@ -721,7 +722,7 @@ frappe.PrintFormatBuilder = Class.extend({ if(fieldtype==="Custom HTML") { // custom html as HTML field df.fieldtype = "HTML"; - df.options = $this.find(".html-content").html(); + df.options = $this.find(".html-content").attr('data-html-content'); } data.push(df); }); diff --git a/frappe/print/page/print_format_builder/print_format_builder_field.html b/frappe/print/page/print_format_builder/print_format_builder_field.html index 67988bf842..89bc0b2d3a 100644 --- a/frappe/print/page/print_format_builder/print_format_builder_field.html +++ b/frappe/print/page/print_format_builder/print_format_builder_field.html @@ -3,22 +3,26 @@ title="{{ __("Hidden") }}"{% } %} data-fieldname="{%= field.fieldname %}" data-label="{{ field.label }}" - + {% if field.align %}data-align="{{ field.align }}"{% endif %} data-fieldtype="{%= field.fieldtype %}" {% if(field.fieldtype==="Table") { %} data-columns="{%= me.get_visible_columns_string(field) %}" data-doctype="{%= field.options %}" {% } %}> + {% if !in_list(["Table", "HTML", "Custom HTML"], field.fieldtype) %} + {% endif %} {% if(field.fieldtype==="Custom HTML") { %}
{%= __("Edit HTML") %}
-
{%= field.options || me.get_no_content() %}
+
+ {{ field.options || me.get_no_content() }}
{% } else { %} {{ field.label }} {% if(field.fieldtype==="Table") { %} diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index 7ad3138005..31abbb4cba 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -175,7 +175,7 @@ frappe.views.QueryReport = Class.extend({ } }, pdf_report: function() { - base_url = frappe.urllib.get_base_url(); + base_url = frappe.urllib.get_base_url(); print_css = frappe.boot.print_css; if(!frappe.model.can_print(this.report_doc.ref_doctype)) { diff --git a/frappe/templates/generators/web_form.html b/frappe/templates/generators/web_form.html index acaa467d9f..426f338c88 100644 --- a/frappe/templates/generators/web_form.html +++ b/frappe/templates/generators/web_form.html @@ -7,7 +7,7 @@ {% endblock %} {% block breadcrumbs %} -{% if has_header %} +{% if has_header and login_required %} {% include "templates/includes/breadcrumbs.html" %} {% endif %} {% endblock %} @@ -15,8 +15,10 @@ {% block header_actions %} {% if not read_only and has_header %}
- - {{ _("Cancel") }} + {% if login_required -%} + + {{ _("Cancel") }} + {%- endif %}
@@ -43,7 +45,7 @@

{{ introduction_text }}

{% endif %} -
+
{% if _login_required %}
@@ -340,8 +342,7 @@ frappe.ready(function() { frappe.file_reading = false; frappe.allow_incomplete = {{ allow_incomplete or 0 }}; - frappe.success_message = "{{ success_message or "" }}"; - frappe.success_link = '{{ success_message }}

{{ _("Continue") }}

' + frappe.success_link = '

{{ success_message or _("Your information has been submitted") }}

{{ _("Continue") }}

' frappe.datepicker_format = "{{ frappe.date_format.replace('yyyy', 'yy') }}"; frappe.web_form_doctype = "{{ doc_type }}"; frappe.web_form_name = "{{ name }}"; @@ -349,6 +350,7 @@ frappe.ready(function() { frappe.is_read_only = {{ 1 if read_only else 0 }}; frappe.doc_name = "{{ frappe.form_dict.name or "" }}"; frappe.form_dirty = false; + frappe.login_required = {{ 1 if login_required else 0 }}; frappe.max_attachment_size = {{ max_attachment_size }}; moment.defaultFormat = "{{ frappe.date_format.upper() }}"; {% if row_template %}frappe.web_form_row_template = "{{ row_template }}";{% endif %} @@ -627,22 +629,25 @@ frappe.ready(function() { callback: function(data) { if(!data.exc) { frappe.doc_name = data.message; - if(frappe.success_message) { + if(!frappe.login_required) { $form.addClass("hide"); - $(".comments, .introduction").addClass("hide"); + $(".comments, .introduction, .page-head").addClass("hide"); scroll(0, 0); - set_message(frappe.success_message); + set_message(frappe.success_link, true); } else { set_message(__('Saved')); } - if(frappe.is_new) { + + if(frappe.is_new && frappe.login_required) { + // reload page (with ID) window.location.href = window.location.pathname + "?name=" + frappe.doc_name; } if(for_payment && data.message) { + // redirect to payment window.location.href = data.message; } } else { - set_message(__('Not Saved')); + frappe.msgprint(__('There were errors. Please report this.')); } }, always: function() { @@ -666,14 +671,16 @@ frappe.ready(function() { + text.join('
')); } - function set_message(msg) { + function set_message(msg, permanent) { $(".form-message") .html(msg) .removeClass("hide"); - setTimeout(function() { - $(".form-message").addClass('hide'); - }, 5000); + if(!permanent) { + setTimeout(function() { + $(".form-message").addClass('hide'); + }, 5000); + } } // submit diff --git a/frappe/website/doctype/web_form_field/web_form_field.json b/frappe/website/doctype/web_form_field/web_form_field.json index 563039a0f7..b8dbe90575 100644 --- a/frappe/website/doctype/web_form_field/web_form_field.json +++ b/frappe/website/doctype/web_form_field/web_form_field.json @@ -15,21 +15,22 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "fieldtype", + "fieldname": "fieldname", "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, - "label": "Fieldtype", + "label": "Fieldname", "length": 0, "no_copy": 0, - "options": "Attach\nCheck\nData\nDate\nDatetime\nFloat\nHTML\nInt\nLink\nSelect\nText\nTable\nSection Break\nColumn Break\nPage Break", "permlevel": 0, "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, @@ -41,20 +42,23 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "fieldname", + "fieldname": "fieldtype", "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, - "label": "Fieldname", + "label": "Fieldtype", "length": 0, "no_copy": 0, + "options": "Attach\nCheck\nData\nDate\nDatetime\nFloat\nHTML\nInt\nLink\nSelect\nText\nTable\nSection Break\nColumn Break\nPage Break", "permlevel": 0, "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, @@ -72,6 +76,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "label": "Label", "length": 0, @@ -80,6 +85,7 @@ "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, @@ -97,6 +103,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Mandatory", "length": 0, @@ -105,6 +112,7 @@ "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, @@ -122,6 +130,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Read Only", "length": 0, @@ -130,6 +139,7 @@ "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, @@ -147,6 +157,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Hidden", "length": 0, @@ -155,6 +166,7 @@ "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, @@ -172,6 +184,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "length": 0, "no_copy": 0, @@ -179,6 +192,7 @@ "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, @@ -196,6 +210,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "label": "Options", "length": 0, @@ -204,6 +219,7 @@ "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, @@ -221,6 +237,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Max Length", "length": 0, @@ -230,6 +247,7 @@ "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, @@ -248,6 +266,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Max Value", "length": 0, @@ -257,6 +276,7 @@ "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, @@ -274,6 +294,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "length": 0, "no_copy": 0, @@ -281,6 +302,7 @@ "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, @@ -298,6 +320,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Description", "length": 0, @@ -306,6 +329,7 @@ "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, @@ -323,6 +347,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "length": 0, "no_copy": 0, @@ -330,6 +355,7 @@ "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, @@ -347,6 +373,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "label": "Default", "length": 0, @@ -355,6 +382,7 @@ "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, @@ -372,7 +400,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-09-26 07:22:54.305948", + "modified": "2016-11-15 12:36:51.897756", "modified_by": "Administrator", "module": "Website", "name": "Web Form Field",