@@ -89,11 +89,15 @@ | |||
<div class="form-group"> | |||
{{ field.options }} | |||
</div> | |||
{% elif field.fieldtype in ("Data", "Date", "Datetime") %} | |||
{% elif field.fieldtype in ("Data", "Date", "Datetime", "Int", "Float") %} | |||
<div class="form-group{% if field.reqd %} has-error{% endif %}"> | |||
{% if with_label %}{{ label(field) }}{% endif %} | |||
<input type="text" class="form-control" {{ properties(field) }} | |||
value="{{ value(field, _doc) }}"> | |||
<input type={{ "number" if field.fieldtype in ("Int", "Float") else "text" }} | |||
class="form-control" {{ properties(field) }} | |||
value="{{ value(field, _doc) }}" | |||
{%- if field.fieldtype=="Int" %} pattern="[0-9]*"{% endif %} | |||
{%- if field.max_value %} max={{ field.max_value }}{% endif %} | |||
{%- if field.max_length %} maxlength={{ field.max_length }}{% endif %}> | |||
{{ help(field) }} | |||
</div> | |||
{% elif field.fieldtype=="Link" %} | |||
@@ -315,6 +319,7 @@ frappe.ready(function() { | |||
frappe.is_new = {{ 1 if frappe.form_dict.new else 0 }}; | |||
frappe.doc_name = "{{ frappe.form_dict.name or "" }}"; | |||
frappe.form_dirty = false; | |||
frappe.max_attachment_size = {{ max_attachment_size }}; | |||
var $form = $("form[data-web-form='{{ name }}']"); | |||
@@ -335,6 +340,16 @@ frappe.ready(function() { | |||
"filename": file.name, | |||
"dataurl": reader.result | |||
}; | |||
if(input.filedata.dataurl.length > frappe.max_attachment_size) { | |||
frappe.msgprint(__('Max file size allowed is {0}MB', | |||
[frappe.max_attachment_size / 1024 / 1024])); | |||
input.filedata = null | |||
// clear attachment | |||
$(input).val(''); | |||
}; | |||
frappe.file_reading = false; | |||
} | |||
@@ -201,8 +201,11 @@ def save_file_on_filesystem(fname, content, content_type=None, is_private=0): | |||
'file_url': file_url | |||
} | |||
def get_max_file_size(): | |||
return conf.get('max_file_size') or 10485760 | |||
def check_max_file_size(content): | |||
max_file_size = conf.get('max_file_size') or 10485760 | |||
max_file_size = get_max_file_size() | |||
file_size = len(content) | |||
if file_size > max_file_size: | |||
@@ -114,14 +114,22 @@ def add_sidebar_data(context): | |||
if not context.sidebar_items: | |||
sidebar_items = frappe.cache().hget('portal_menu_items', frappe.session.user) | |||
print sidebar_items | |||
if sidebar_items == None: | |||
sidebar_items = [] | |||
roles = frappe.get_roles() | |||
sidebar_items = frappe.get_all('Portal Menu Item', | |||
fields=['title', 'route', 'reference_doctype', 'role'], | |||
filters={'enabled': 1, 'parent': 'Portal Settings'}, order_by='idx asc') | |||
portal_settings = frappe.get_doc('Portal Settings', 'Portal Settings') | |||
# filter sidebar items by role | |||
sidebar_items = filter(lambda i: i.role==None or i.role in roles, sidebar_items) | |||
def add_items(sidebar_items, menu_field): | |||
for d in portal_settings.get(menu_field): | |||
if d.enabled and ((not d.role) or d.role in roles): | |||
sidebar_items.append(d.as_dict()) | |||
if not portal_settings.hide_standard_menu: | |||
add_items(sidebar_items, 'menu') | |||
if portal_settings.custom_menu: | |||
add_items(sidebar_items, 'custom_menu') | |||
frappe.cache().hset('portal_menu_items', frappe.session.user, sidebar_items) | |||
@@ -37,6 +37,58 @@ | |||
"set_only_once": 0, | |||
"unique": 0 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "standard_menu_items", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Standard Sidebar Menu", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"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": 0, | |||
"columns": 0, | |||
"fieldname": "hide_standard_menu", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Hide Standard Menu", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"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, | |||
@@ -63,6 +115,59 @@ | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "custom_sidebar_menu", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Custom Sidebar Menu", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"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": 0, | |||
"columns": 0, | |||
"fieldname": "custom_menu", | |||
"fieldtype": "Table", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Custom Menu Items", | |||
"length": 0, | |||
"no_copy": 0, | |||
"options": "Portal Menu Item", | |||
"permlevel": 0, | |||
"precision": "", | |||
"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 | |||
} | |||
], | |||
"hide_heading": 0, | |||
@@ -75,7 +180,7 @@ | |||
"issingle": 1, | |||
"istable": 0, | |||
"max_attachments": 0, | |||
"modified": "2016-09-23 06:34:18.718351", | |||
"modified": "2016-09-26 06:57:56.109257", | |||
"modified_by": "Administrator", | |||
"module": "Website", | |||
"name": "Portal Settings", | |||
@@ -10,6 +10,7 @@ from frappe.utils.file_manager import save_file, remove_file_by_url | |||
from frappe.website.utils import get_comment_list | |||
from frappe.custom.doctype.customize_form.customize_form import docfield_properties | |||
from frappe.integration_broker.doctype.integration_service.integration_service import get_integration_controller | |||
from frappe.utils.file_manager import get_max_file_size | |||
class WebForm(WebsiteGenerator): | |||
website = frappe._dict( | |||
@@ -164,6 +165,7 @@ def get_context(context): | |||
self.add_custom_context_and_script(context) | |||
self.add_payment_gateway_url(context) | |||
context.max_attachment_size = get_max_file_size() | |||
def add_payment_gateway_url(self, context): | |||
if context.doc and self.accept_payment: | |||
@@ -25,7 +25,7 @@ | |||
"label": "Fieldtype", | |||
"length": 0, | |||
"no_copy": 0, | |||
"options": "Attach\nCheck\nData\nDate\nDatetime\nHTML\nLink\nSelect\nText\nTable\nSection Break\nColumn Break\nPage Break", | |||
"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, | |||
@@ -210,6 +210,59 @@ | |||
"set_only_once": 0, | |||
"unique": 0 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "max_length", | |||
"fieldtype": "Int", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Max Length", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"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": 0, | |||
"columns": 0, | |||
"depends_on": "eval:doc.fieldtype=='Int'", | |||
"fieldname": "max_value", | |||
"fieldtype": "Int", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Max Value", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"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, | |||
@@ -319,7 +372,7 @@ | |||
"issingle": 0, | |||
"istable": 1, | |||
"max_attachments": 0, | |||
"modified": "2016-09-19 08:02:36.033335", | |||
"modified": "2016-09-26 07:22:54.305948", | |||
"modified_by": "Administrator", | |||
"module": "Website", | |||
"name": "Web Form Field", | |||
@@ -15,6 +15,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "section_title", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
@@ -39,7 +40,8 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "Title / headline of your page", | |||
"columns": 0, | |||
"description": "", | |||
"fieldname": "title", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
@@ -64,15 +66,15 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"default": "1", | |||
"fieldname": "show_title", | |||
"fieldtype": "Check", | |||
"columns": 0, | |||
"fieldname": "route", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Show Title", | |||
"label": "Route", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
@@ -84,13 +86,14 @@ | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
"unique": 1 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "Begin this page with a slideshow of images", | |||
"columns": 0, | |||
"description": "", | |||
"fieldname": "slideshow", | |||
"fieldtype": "Link", | |||
"hidden": 0, | |||
@@ -116,6 +119,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "cb1", | |||
"fieldtype": "Column Break", | |||
"hidden": 0, | |||
@@ -140,18 +144,18 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"fieldname": "route", | |||
"fieldtype": "Data", | |||
"columns": 0, | |||
"fieldname": "published", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Route", | |||
"label": "Published", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
@@ -159,23 +163,26 @@ | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 1 | |||
"unique": 0 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"fieldname": "published", | |||
"columns": 0, | |||
"default": "1", | |||
"fieldname": "show_title", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Published", | |||
"label": "Show Title", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
@@ -189,18 +196,19 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "Page content", | |||
"fieldname": "sb1", | |||
"fieldtype": "Section Break", | |||
"columns": 0, | |||
"fieldname": "show_sidebar", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Content", | |||
"label": "Show Sidebar", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
@@ -214,15 +222,16 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "Content in markdown format that appears on the main side of your page", | |||
"fieldname": "main_section", | |||
"fieldtype": "Text Editor", | |||
"columns": 0, | |||
"description": "Page content", | |||
"fieldname": "sb1", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Main Section", | |||
"label": "Content", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
@@ -239,17 +248,19 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"fieldname": "fold_10", | |||
"fieldtype": "Fold", | |||
"columns": 0, | |||
"description": "Content in markdown format that appears on the main side of your page", | |||
"fieldname": "main_section", | |||
"fieldtype": "Text Editor", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Main Section", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
@@ -262,7 +273,8 @@ | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"collapsible": 1, | |||
"columns": 0, | |||
"fieldname": "custom_javascript", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
@@ -287,6 +299,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "Add code as <script>", | |||
"fieldname": "insert_code", | |||
"fieldtype": "Check", | |||
@@ -312,6 +325,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"depends_on": "insert_code", | |||
"fieldname": "javascript", | |||
"fieldtype": "Code", | |||
@@ -337,7 +351,8 @@ | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"collapsible": 1, | |||
"columns": 0, | |||
"fieldname": "custom_css", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
@@ -362,6 +377,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "insert_style", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
@@ -386,6 +402,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"depends_on": "insert_style", | |||
"fieldname": "css", | |||
"fieldtype": "Code", | |||
@@ -412,6 +429,33 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "settings", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Settings", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"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": 0, | |||
"columns": 0, | |||
"fieldname": "section_break_17", | |||
"fieldtype": "Section Break", | |||
"hidden": 0, | |||
@@ -436,6 +480,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "enable_comments", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
@@ -460,6 +505,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "text_align", | |||
"fieldtype": "Select", | |||
"hidden": 0, | |||
@@ -485,6 +531,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "column_break_20", | |||
"fieldtype": "Column Break", | |||
"hidden": 0, | |||
@@ -509,6 +556,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "0 is highest", | |||
"fieldname": "idx", | |||
"fieldtype": "Int", | |||
@@ -534,6 +582,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"depends_on": "eval:!doc.__islocal", | |||
"description": "", | |||
"fieldname": "sb2", | |||
@@ -560,6 +609,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "Description for search engine optimization.", | |||
"fieldname": "description", | |||
"fieldtype": "Small Text", | |||
@@ -585,6 +635,7 @@ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "HTML for header section. Optional", | |||
"fieldname": "header", | |||
"fieldtype": "Text", | |||
@@ -618,7 +669,7 @@ | |||
"issingle": 0, | |||
"istable": 0, | |||
"max_attachments": 20, | |||
"modified": "2016-07-08 06:22:38.925289", | |||
"modified": "2016-09-26 07:09:08.700666", | |||
"modified_by": "Administrator", | |||
"module": "Website", | |||
"name": "Web Page", | |||
@@ -24,6 +24,9 @@ class WebPage(WebsiteGenerator): | |||
return self.title | |||
def get_context(self, context): | |||
if context.main_section == None: | |||
context.main_section = '' | |||
# if static page, get static content | |||
if context.slideshow: | |||
context.update(get_slideshow(self)) | |||
@@ -67,7 +70,7 @@ class WebPage(WebsiteGenerator): | |||
def set_breadcrumbs(self, context): | |||
"""Build breadcrumbs template (deprecated)""" | |||
if not "no_breadcrumbs" in context: | |||
if "<!-- no-breadcrumbs -->" in context.main_section or '': | |||
if "<!-- no-breadcrumbs -->" in context.main_section: | |||
context.no_breadcrumbs = 1 | |||
def set_title_and_header(self, context): | |||
@@ -303,6 +303,9 @@ def load_properties(page_info): | |||
if "<!-- no-breadcrumbs -->" in page_info.source: | |||
page_info.no_breadcrumbs = 1 | |||
if "<!-- show-sidebar -->" in page_info.source: | |||
page_info.show_sidebar = 1 | |||
if "<!-- no-header -->" in page_info.source: | |||
page_info.no_header = 1 | |||
else: | |||