From 7f771397746ef4d2650725c5b262c3d25a502fb7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 26 Sep 2016 17:56:38 +0530 Subject: [PATCH] [fix] minor date-format --- frappe/templates/generators/web_form.html | 1 + frappe/utils/jinja.py | 5 +- .../website_settings/website_settings.js | 8 +- .../website_settings/website_settings.json | 98 +++++++++++++++---- 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/frappe/templates/generators/web_form.html b/frappe/templates/generators/web_form.html index 93b3e9a124..3f1d0790fe 100644 --- a/frappe/templates/generators/web_form.html +++ b/frappe/templates/generators/web_form.html @@ -320,6 +320,7 @@ frappe.ready(function() { frappe.doc_name = "{{ frappe.form_dict.name or "" }}"; frappe.form_dirty = false; frappe.max_attachment_size = {{ max_attachment_size }}; + moment.defaultFormat = "{{ frappe.date_format.upper() }}"; var $form = $("form[data-web-form='{{ name }}']"); diff --git a/frappe/utils/jinja.py b/frappe/utils/jinja.py index 10bb67eb0f..62affcd440 100644 --- a/frappe/utils/jinja.py +++ b/frappe/utils/jinja.py @@ -61,6 +61,8 @@ def get_allowed_functions_for_jenv(): import mimetypes datautils = {} + date_format = frappe.db.get_default("date_format") or "yyyy-mm-dd" + for key, obj in frappe.utils.data.__dict__.items(): if key.startswith("_"): # ignore @@ -80,6 +82,7 @@ def get_allowed_functions_for_jenv(): "get_url": frappe.utils.get_url, 'format': frappe.format_value, "format_value": frappe.format_value, + 'date_format': date_format, "format_date": frappe.utils.data.global_date_format, "form_dict": getattr(frappe.local, 'form_dict', {}), "local": frappe.local, @@ -109,7 +112,7 @@ def get_allowed_functions_for_jenv(): if not frappe.flags.in_setup_help: out['get_visible_columns'] = frappe.get_attr("frappe.www.print.get_visible_columns") - out['frappe']['date_format'] = frappe.db.get_default("date_format") or "yyyy-mm-dd" + out['frappe']['date_format'] = date_format out['frappe']["db"] = { "get_value": frappe.db.get_value, "get_default": frappe.db.get_default, diff --git a/frappe/website/doctype/website_settings/website_settings.js b/frappe/website/doctype/website_settings/website_settings.js index a517bfd2ae..cf8d9497f3 100644 --- a/frappe/website/doctype/website_settings/website_settings.js +++ b/frappe/website/doctype/website_settings/website_settings.js @@ -55,7 +55,7 @@ $.extend(cur_frm.cscript, { cur_frm.fields_dict.top_bar_items.grid.refresh(); } }, - + set_parent_label_options_footer: function() { frappe.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options = this.get_parent_options("footer_items"); @@ -81,9 +81,9 @@ $.extend(cur_frm.cscript, { cur_frm.cscript.set_banner_from_image = function(doc) { if(!doc.banner_image) { - msgprint(__("Select a Banner Image first.")); + msgprint(__("Select a Brand Image first.")); } var src = doc.banner_image; - cur_frm.set_value("banner_html", ""); + cur_frm.set_value("brand_html", ""); } diff --git a/frappe/website/doctype/website_settings/website_settings.json b/frappe/website/doctype/website_settings/website_settings.json index 798e660141..0599e5e547 100644 --- a/frappe/website/doctype/website_settings/website_settings.json +++ b/frappe/website/doctype/website_settings/website_settings.json @@ -8,11 +8,13 @@ "docstatus": 0, "doctype": "DocType", "document_type": "Other", + "editable_grid": 0, "fields": [ { "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "sb0", "fieldtype": "Section Break", "hidden": 0, @@ -37,6 +39,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Link that is the website home page. Standard Links (index, login, products, blog, about, contact)", "fieldname": "home_page", "fieldtype": "Data", @@ -63,6 +66,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "cb4", "fieldtype": "Column Break", "hidden": 0, @@ -86,6 +90,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Show title in browser window as \"Prefix - title\"", "fieldname": "title_prefix", "fieldtype": "Data", @@ -111,6 +116,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "section_break_6", "fieldtype": "Section Break", "hidden": 0, @@ -135,6 +141,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "default": "Standard", "fieldname": "website_theme", "fieldtype": "Link", @@ -162,6 +169,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "website_theme_image", "fieldtype": "Image", "hidden": 1, @@ -188,6 +196,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "website_theme_image_link", "fieldtype": "Code", "hidden": 1, @@ -213,18 +222,19 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, - "description": "", - "fieldname": "banner", + "columns": 0, + "fieldname": "brand", "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Banner", + "label": "Brand", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -238,6 +248,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Select an image of approx width 150px with a transparent background for best results.", "fieldname": "banner_image", "fieldtype": "Attach Image", @@ -246,7 +257,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Banner Image", + "label": "Brand Image", "length": 0, "no_copy": 0, "options": "", @@ -264,14 +275,16 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "set_banner_from_image", - "fieldtype": "Button", + "columns": 0, + "description": "Brand is what appears on the top-left of the toolbar. If it is an image, make sure it\nhas a transparent background and use the <img /> tag. Keep size as 200px x 30px", + "fieldname": "brand_html", + "fieldtype": "Code", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Set Banner from Image", + "label": "Brand HTML", "length": 0, "no_copy": 0, "permlevel": 0, @@ -288,15 +301,15 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "Banner is above the Top Menu Bar.", - "fieldname": "banner_html", - "fieldtype": "Code", + "columns": 0, + "fieldname": "set_banner_from_image", + "fieldtype": "Button", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Banner HTML", + "label": "Set Banner from Image", "length": 0, "no_copy": 0, "permlevel": 0, @@ -313,6 +326,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, + "columns": 0, "description": "", "fieldname": "top_bar", "fieldtype": "Section Break", @@ -338,15 +352,42 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "Brand is what appears on the top-left of the toolbar. If it is an image, make sure it\nhas a transparent background and use the <img /> tag. Keep size as 200px x 30px", - "fieldname": "brand_html", - "fieldtype": "Code", + "columns": 0, + "fieldname": "top_bar_items", + "fieldtype": "Table", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Brand HTML", + "label": "Top Bar Items", + "length": 0, + "no_copy": 0, + "options": "Top Bar Item", + "permlevel": 0, + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 1, + "columns": 0, + "description": "", + "fieldname": "banner", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Banner", "length": 0, "no_copy": 0, "permlevel": 0, @@ -363,17 +404,18 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "top_bar_items", - "fieldtype": "Table", + "columns": 0, + "description": "Banner is above the Top Menu Bar.", + "fieldname": "banner_html", + "fieldtype": "Code", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Top Bar Items", + "label": "Banner HTML", "length": 0, "no_copy": 0, - "options": "Top Bar Item", "permlevel": 0, "print_hide": 0, "print_hide_if_no_value": 0, @@ -388,6 +430,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, + "columns": 0, "fieldname": "footer", "fieldtype": "Section Break", "hidden": 0, @@ -412,6 +455,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "copyright", "fieldtype": "Data", "hidden": 0, @@ -436,6 +480,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Address and other legal information you may want to put in the footer.", "fieldname": "address", "fieldtype": "Text Editor", @@ -461,6 +506,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "footer_items", "fieldtype": "Table", "hidden": 0, @@ -486,6 +532,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "hide_footer_signup", "fieldtype": "Check", "hidden": 0, @@ -511,6 +558,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, + "columns": 0, "fieldname": "integrations", "fieldtype": "Section Break", "hidden": 0, @@ -535,6 +583,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Add Google Analytics ID: eg. UA-89XXX57-1. Please search help on Google Analytics for more information.", "fieldname": "google_analytics_id", "fieldtype": "Data", @@ -560,6 +609,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "column_break_17", "fieldtype": "Column Break", "hidden": 0, @@ -583,6 +633,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, + "columns": 0, "fieldname": "misc_section", "fieldtype": "Section Break", "hidden": 0, @@ -607,6 +658,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [favicon-generator.org]", "fieldname": "favicon", "fieldtype": "Attach", @@ -633,6 +685,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Sub-domain provided by erpnext.com", "fieldname": "subdomain", "fieldtype": "Text", @@ -658,6 +711,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "column_break_28", "fieldtype": "Column Break", "hidden": 0, @@ -681,6 +735,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Disable Customer Signup link in Login page", "fieldname": "disable_signup", "fieldtype": "Check", @@ -706,6 +761,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, + "columns": 0, "fieldname": "section_break_38", "fieldtype": "Section Break", "hidden": 0, @@ -731,6 +787,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "description": "Added HTML in the <head> section of the web page, primarily used for website verification and SEO", "fieldname": "head_html", "fieldtype": "Code", @@ -758,6 +815,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "robots_txt", "fieldtype": "Code", "hidden": 0, @@ -791,7 +849,7 @@ "issingle": 1, "istable": 0, "max_attachments": 10, - "modified": "2016-06-29 03:44:31.762764", + "modified": "2016-09-26 08:25:22.196272", "modified_by": "Administrator", "module": "Website", "name": "Website Settings",