Ver código fonte

Merge pull request #6886 from rmehta/web-form-fixes

feat: various fixes to Web Form and content type selection for Web Page and Blog Post
version-14
Rushabh Mehta 6 anos atrás
committed by GitHub
pai
commit
9200415b25
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: 4AEE18F83AFDEB23
23 arquivos alterados com 2745 adições e 2336 exclusões
  1. +1
    -1
      frappe/database/mariadb/database.py
  2. +3
    -3
      frappe/database/postgres/database.py
  3. +23
    -9
      frappe/model/base_document.py
  4. +10
    -10
      frappe/public/js/frappe/form/controls/check.js
  5. +1
    -6
      frappe/public/js/frappe/ui/messages.js
  6. +3
    -1
      frappe/public/js/frappe/ui/toolbar/navbar.html
  7. +1
    -1
      frappe/public/less/desk.less
  8. +8
    -0
      frappe/public/less/navbar.less
  9. +8
    -0
      frappe/templates/base.html
  10. +2
    -2
      frappe/templates/styles/standard.css
  11. +2
    -6
      frappe/website/css/web_form.css
  12. +496
    -362
      frappe/website/doctype/blog_post/blog_post.json
  13. +3
    -4
      frappe/website/doctype/blog_post/blog_post.py
  14. +2
    -2
      frappe/website/doctype/web_form/templates/web_form.html
  15. +1415
    -1382
      frappe/website/doctype/web_form/web_form.json
  16. +535
    -535
      frappe/website/doctype/web_form_field/web_form_field.json
  17. +29
    -5
      frappe/website/doctype/web_page/test_web_page.py
  18. +163
    -3
      frappe/website/doctype/web_page/web_page.json
  19. +4
    -3
      frappe/website/doctype/web_page/web_page.py
  20. +12
    -1
      frappe/website/js/web_form_class.js
  21. +5
    -0
      frappe/website/router.py
  22. +16
    -0
      frappe/website/utils.py
  23. +3
    -0
      frappe/website/website_generator.py

+ 1
- 1
frappe/database/mariadb/database.py Ver arquivo

@@ -27,7 +27,7 @@ class MariaDBDatabase(Database):
self.type_map = {
'Currency': ('decimal', '18,6'),
'Int': ('int', '11'),
'Long Int': ('bigint', '20'), # convert int to bigint if length is more than 11
'Long Int': ('bigint', '20'),
'Float': ('decimal', '18,6'),
'Percent': ('decimal', '18,6'),
'Check': ('int', '1'),


+ 3
- 3
frappe/database/postgres/database.py Ver arquivo

@@ -32,7 +32,7 @@ class PostgresDatabase(Database):
self.type_map = {
'Currency': ('decimal', '18,6'),
'Int': ('bigint', None),
'Long Int': ('bigint', None), # convert int to bigint if length is more than 11
'Long Int': ('bigint', None),
'Float': ('decimal', '18,6'),
'Percent': ('decimal', '18,6'),
'Check': ('smallint', None),
@@ -40,8 +40,8 @@ class PostgresDatabase(Database):
'Long Text': ('text', ''),
'Code': ('text', ''),
'Text Editor': ('text', ''),
'Markdown Editor': ('longtext', ''),
'HTML Editor': ('longtext', ''),
'Markdown Editor': ('text', ''),
'HTML Editor': ('text', ''),
'Date': ('date', ''),
'Datetime': ('timestamp', None),
'Time': ('time', '6'),


+ 23
- 9
frappe/model/base_document.py Ver arquivo

@@ -16,6 +16,12 @@ from frappe.utils.password import get_decrypted_password, set_encrypted_password
from frappe.utils import (cint, flt, now, cstr, strip_html, getdate, get_datetime, to_timedelta,
sanitize_html, sanitize_email, cast_fieldtype)

max_positive_value = {
'smallint': 2 ** 15,
'int': 2 ** 31,
'bigint': 2 ** 63
}

_classes = {}

def get_controller(doctype):
@@ -549,7 +555,6 @@ class BaseDocument(object):
# single doctype value type is mediumtext
return

column_types_to_check_length = ('varchar', 'int', 'bigint')
type_map = frappe.db.type_map

for fieldname, value in iteritems(self.get_valid_dict()):
@@ -560,20 +565,29 @@ class BaseDocument(object):
continue

column_type = type_map[df.fieldtype][0] or None
default_column_max_length = type_map[df.fieldtype][1] or None

if df and df.fieldtype in type_map and column_type in column_types_to_check_length:
if column_type == 'varchar':
default_column_max_length = type_map[df.fieldtype][1] or None
max_length = cint(df.get("length")) or cint(default_column_max_length)

if len(cstr(value)) > max_length:
if self.parentfield and self.idx:
reference = _("{0}, Row {1}").format(_(self.doctype), self.idx)
self.throw_length_exceeded_error(df, max_length, value)

elif column_type in ('int', 'bigint', 'smallint'):
max_length = max_positive_value[column_type]

if abs(value) > max_length:
self.throw_length_exceeded_error(df, max_length, value)

else:
reference = "{0} {1}".format(_(self.doctype), self.name)
def throw_length_exceeded_error(self, df, max_length, value):
if self.parentfield and self.idx:
reference = _("{0}, Row {1}").format(_(self.doctype), self.idx)

else:
reference = "{0} {1}".format(_(self.doctype), self.name)

frappe.throw(_("{0}: '{1}' ({3}) will get truncated, as max characters allowed is {2}")\
.format(reference, _(df.label), max_length, value), frappe.CharacterLengthExceededError, title=_('Value too big'))
frappe.throw(_("{0}: '{1}' ({3}) will get truncated, as max characters allowed is {2}")\
.format(reference, _(df.label), max_length, value), frappe.CharacterLengthExceededError, title=_('Value too big'))

def _validate_update_after_submit(self):
# get the full doc with children


+ 10
- 10
frappe/public/js/frappe/form/controls/check.js Ver arquivo

@@ -1,16 +1,16 @@
frappe.ui.form.ControlCheck = frappe.ui.form.ControlData.extend({
input_type: "checkbox",
make_wrapper: function() {
this.$wrapper = $('<div class="form-group frappe-control">\
<div class="checkbox">\
<label>\
<span class="input-area"></span>\
<span class="disp-area"></span>\
<span class="label-area small"></span>\
</label>\
<p class="help-box small text-muted"></p>\
</div>\
</div>').appendTo(this.parent);
this.$wrapper = $(`<div class="form-group frappe-control">
<div class="checkbox">
<label>
<span class="input-area"></span>
<span class="disp-area"></span>
<span class="label-area ${this.df.is_web_form ? "" : "small"}"></span>
</label>
<p class="help-box small text-muted"></p>
</div>
</div>`).appendTo(this.parent);
},
set_input_areas: function() {
this.label_area = this.label_span = this.$wrapper.find(".label-area").get(0);


+ 1
- 6
frappe/public/js/frappe/ui/messages.js Ver arquivo

@@ -100,12 +100,7 @@ frappe.msgprint = function(msg, title) {

if(data.message instanceof Array) {
data.message.forEach(function(m) {
const msg = {
message: m,
indicator: data.indicator,
title: data.title
}
frappe.msgprint(msg);
frappe.msgprint(m);
});
return;
}


+ 3
- 1
frappe/public/js/frappe/ui/toolbar/navbar.html Ver arquivo

@@ -4,7 +4,9 @@
<a class="navbar-brand toggle-sidebar visible-xs visible-sm">
<i class="octicon octicon-three-bars"></i>
</a>
<a class="navbar-brand navbar-home hidden-xs hidden-sm" href="#">Home</a>
<a class="navbar-brand navbar-home hidden-xs hidden-sm" href="#">
<img src="/assets/frappe/images/frappe-framework-logo.png">
</a>
<ul class="nav navbar-nav" id="navbar-breadcrumbs">
</ul>
</div>


+ 1
- 1
frappe/public/less/desk.less Ver arquivo

@@ -761,7 +761,7 @@ li.user-progress {
}

.checkbox label {
padding-left: 0px;
padding-left: 2px;
}

.checkbox input[type=checkbox] {


+ 8
- 0
frappe/public/less/navbar.less Ver arquivo

@@ -33,6 +33,14 @@
.badge {
font-weight: normal;
}

.navbar-home {
img {
width: 24px;
margin-right: 0px;
margin-top: -3px;
}
}
}

.navbar-icon-home {


+ 8
- 0
frappe/templates/base.html Ver arquivo

@@ -16,9 +16,17 @@
{% endblock %}
{%- block head -%}
{% block meta_block %}{% endblock %}

{% if head_html is defined -%}
{{ head_html or "" }}
{%- endif %}

{% if meta_tags %}
{% for key in meta_tags %}
{% if meta_tags[key] %}<meta name="{{ key }}" content="{{ meta_tags[key] }}" />{% endif %}
{% endfor %}
{% endif %}

{%- for link in web_include_css %}
<link type="text/css" rel="stylesheet" href="{{ link|abs_url }}">
{%- endfor -%}


+ 2
- 2
frappe/templates/styles/standard.css Ver arquivo

@@ -1,7 +1,7 @@
@media screen {
.print-format-gutter {
background-color: #ddd;
padding: 15px 0px;
background-color: #d1d8dd;
padding: 30px 0px;
}
.print-format {
background-color: white;


+ 2
- 6
frappe/website/css/web_form.css Ver arquivo

@@ -11,8 +11,8 @@
font-weight: normal;
}

input[type='checkbox'] {
margin-top: 3px;
.checkbox .label-area {
padding-left: 3px;
}

.page-header-actions-block .btn-delete {
@@ -32,10 +32,6 @@ input[type='checkbox'] {
display: none;
}

.checkbox label {
font-size: 12px;
}

.web-form-page, .web-form-page .section {
padding: 20px 0px;
}


+ 496
- 362
frappe/website/doctype/blog_post/blog_post.json Ver arquivo

@@ -1,394 +1,528 @@
{
"allow_copy": 0,
"allow_guest_to_view": 1,
"allow_import": 1,
"allow_rename": 0,
"beta": 0,
"creation": "2013-03-28 10:35:30",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"engine": "InnoDB",
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 1,
"allow_import": 1,
"allow_rename": 0,
"beta": 0,
"creation": "2013-03-28 10:35:30",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Title",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Title",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published_on",
"fieldtype": "Date",
"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": "Published On",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published_on",
"fieldtype": "Date",
"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": "Published On",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published",
"fieldtype": "Check",
"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": "Published",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published",
"fieldtype": "Check",
"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": "Published",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"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,
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"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,
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "blog_category",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Blog Category",
"length": 0,
"no_copy": 0,
"options": "Blog Category",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "blog_category",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Blog Category",
"length": 0,
"no_copy": 0,
"options": "Blog Category",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "blogger",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Blogger",
"length": 0,
"no_copy": 0,
"options": "Blogger",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "blogger",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Blogger",
"length": 0,
"no_copy": 0,
"options": "Blogger",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"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": "Route",
"length": 0,
"no_copy": 0,
"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,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"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": "Route",
"length": 0,
"no_copy": 0,
"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,
"translatable": 0,
"unique": 1
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_5",
"fieldtype": "Section Break",
"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,
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_5",
"fieldtype": "Section Break",
"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,
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Description for listing page, in plain text, only a couple of lines. (max 140 characters)",
"fieldname": "blog_intro",
"fieldtype": "Small Text",
"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": "Blog Intro",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Description for listing page, in plain text, only a couple of lines. (max 140 characters)",
"fieldname": "blog_intro",
"fieldtype": "Small Text",
"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": "Blog Intro",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "content",
"fieldtype": "Text Editor",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 1,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Content",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Rich Text",
"fieldname": "content_type",
"fieldtype": "Select",
"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": "Content Type",
"length": 0,
"no_copy": 0,
"options": "Rich Text\nMarkdown\nHTML",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "email_sent",
"fieldtype": "Check",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Sent",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.content_type === 'Rich Text'",
"fieldname": "content",
"fieldtype": "Text Editor",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 1,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Content",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.content_type === 'Markdown'",
"fieldname": "content_md",
"fieldtype": "Markdown Editor",
"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": "Content (Markdown)",
"length": 0,
"no_copy": 0,
"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,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.content_type === 'HTML'",
"fieldname": "content_html",
"fieldtype": "HTML Editor",
"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": "Content (HTML)",
"length": 0,
"no_copy": 0,
"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,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "email_sent",
"fieldtype": "Check",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Sent",
"length": 0,
"no_copy": 0,
"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,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
"has_web_view": 1,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-quote-left",
"idx": 1,
"image_view": 0,
"in_create": 0,
"is_published_field": "published",
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 5,
"modified": "2017-03-06 16:25:33.410910",
"modified_by": "Administrator",
"module": "Website",
"name": "Blog Post",
"owner": "Administrator",
],
"has_web_view": 1,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-quote-left",
"idx": 1,
"image_view": 0,
"in_create": 0,
"is_published_field": "published",
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 5,
"modified": "2019-02-01 16:34:03.418705",
"modified_by": "Administrator",
"module": "Website",
"name": "Blog Post",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Website Manager",
"set_user_permissions": 1,
"share": 1,
"submit": 0,
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Website Manager",
"set_user_permissions": 1,
"share": 1,
"submit": 0,
"write": 1
},
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Blogger",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Blogger",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"route": "/blog",
"show_name_in_global_search": 0,
"sort_order": "ASC",
"title_field": "title",
"track_changes": 1,
"track_seen": 0
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"route": "/blog",
"show_name_in_global_search": 0,
"sort_order": "ASC",
"title_field": "title",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}

+ 3
- 4
frappe/website/doctype/blog_post/blog_post.py Ver arquivo

@@ -8,7 +8,7 @@ from frappe import _
from frappe.website.website_generator import WebsiteGenerator
from frappe.website.render import clear_cache
from frappe.utils import today, cint, global_date_format, get_fullname, strip_html_tags, markdown
from frappe.website.utils import find_first_image, get_comment_list
from frappe.website.utils import (find_first_image, get_comment_list, get_html_content_based_on_type)

class BlogPost(WebsiteGenerator):
website = frappe._dict(
@@ -58,14 +58,13 @@ class BlogPost(WebsiteGenerator):

context.description = self.blog_intro or self.content[:140]

context.content = get_html_content_based_on_type(self, 'content', self.content_type)

context.metatags = {
"name": self.title,
"description": context.description,
}

if "<!-- markdown -->" in context.content:
context.content = markdown(context.content)

image = find_first_image(self.content)
if image:
context.metatags["image"] = image


+ 2
- 2
frappe/website/doctype/web_form/templates/web_form.html Ver arquivo

@@ -22,7 +22,7 @@
{%- endif %}
{% if not is_list %}
<button type="submit" class="btn btn-primary btn-sm btn-form-submit">
{{ _("Save") }}</button>
{{ _(button_label or "Save") }}</button>
{% endif %}
</div>
{% endif %}
@@ -152,7 +152,7 @@
{% if (loop.index == layout|len or frappe.form_dict.new) %}
{% if not read_only %}
<button type="submit" class="btn btn-primary btn-sm btn-form-submit">
{{ _("Save") }}</button>
{{ _(button_label or "Save") }}</button>
{% endif %}
{% elif layout|len > 1 %}
<button class="btn btn-primary btn-sm btn-change-section"


+ 1415
- 1382
frappe/website/doctype/web_form/web_form.json
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 535
- 535
frappe/website/doctype/web_form_field/web_form_field.json
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 29
- 5
frappe/website/doctype/web_page/test_web_page.py Ver arquivo

@@ -7,6 +7,11 @@ from frappe.tests import set_request

test_records = frappe.get_test_records('Web Page')

def get_page_content(route):
set_request(method='GET', path = route)
response = frappe.website.render.render()
return frappe.as_unicode(response.data)

class TestWebPage(unittest.TestCase):
def setUp(self):
frappe.db.sql("delete from `tabWeb Page`")
@@ -19,14 +24,33 @@ class TestWebPage(unittest.TestCase):
resolve_route("test-web-page-1/test-web-page-3")

def test_base_template(self):
set_request(method='GET', path = '/_test/_test_custom_base.html')

response = frappe.website.render.render()
content = get_page_content('/_test/_test_custom_base.html')

# assert the text in base template is rendered
self.assertTrue('<h1>This is for testing</h1>' in frappe.as_unicode(response.data))
self.assertTrue('<h1>This is for testing</h1>' in frappe.as_unicode(content))

# assert template block rendered
self.assertTrue('<p>Test content</p>' in frappe.as_unicode(response.data))
self.assertTrue('<p>Test content</p>' in frappe.as_unicode(content))

def test_content_type(self):
web_page = frappe.get_doc(dict(
doctype = 'Web Page',
title = 'Test Content Type',
published = 1,
content_type = 'Rich Text',
main_section = 'rich text',
main_section_md = '# h1\n\markdown content',
main_section_html = '<div>html content</div>'
)).insert()

self.assertTrue('rich text' in get_page_content('/test-content-type'))

web_page.content_type = 'Markdown'
web_page.save()
self.assertTrue('markdown content' in get_page_content('/test-content-type'))

web_page.content_type = 'HTML'
web_page.save()
self.assertTrue('html content' in get_page_content('/test-content-type'))



+ 163
- 3
frappe/website/doctype/web_page/web_page.json Ver arquivo

@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 1,
"allow_import": 1,
"allow_rename": 0,
@@ -14,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -39,10 +41,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -69,10 +73,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -99,10 +105,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -130,10 +138,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -158,11 +168,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50%"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -188,10 +200,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -219,10 +233,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -249,10 +265,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -279,10 +297,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -309,14 +329,51 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Rich Text",
"fieldname": "content_type",
"fieldtype": "Select",
"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": "Content Type",
"length": 0,
"no_copy": 0,
"options": "Rich Text\nMarkdown\nHTML",
"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,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.content_type==='Rich Text'",
"description": "",
"fieldname": "main_section",
"fieldtype": "Text Editor",
@@ -339,10 +396,78 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.content_type==='Markdown'",
"fieldname": "main_section_md",
"fieldtype": "Markdown Editor",
"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": "Main Section",
"length": 0,
"no_copy": 0,
"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,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.content_type==='HTML'",
"fieldname": "main_section_html",
"fieldtype": "HTML Editor",
"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": "Main Section",
"length": 0,
"no_copy": 0,
"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,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -368,10 +493,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -398,10 +525,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -429,10 +558,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -458,10 +589,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -487,10 +620,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -517,10 +652,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -548,10 +685,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -578,10 +717,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -608,10 +749,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -638,10 +781,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -669,10 +814,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -698,10 +845,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -727,10 +876,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -757,10 +908,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@@ -788,10 +941,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -818,10 +973,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -848,10 +1005,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -879,6 +1038,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@@ -894,7 +1054,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 20,
"modified": "2018-01-16 02:16:05.251006",
"modified": "2019-02-01 16:16:43.182568",
"modified_by": "Administrator",
"module": "Website",
"name": "Web Page",
@@ -902,7 +1062,6 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@@ -929,5 +1088,6 @@
"sort_order": "ASC",
"title_field": "title",
"track_changes": 1,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

+ 4
- 3
frappe/website/doctype/web_page/web_page.py Ver arquivo

@@ -15,20 +15,21 @@ from frappe.utils import get_datetime, now, strip_html
from frappe.utils.jinja import render_template
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
from frappe.website.router import resolve_route
from frappe.website.utils import extract_title, find_first_image, get_comment_list
from frappe.website.utils import (extract_title, find_first_image, get_comment_list,
get_html_content_based_on_type)
from frappe.website.website_generator import WebsiteGenerator


class WebPage(WebsiteGenerator):
def validate(self):
self.validate_dates()
self.set_route()

def get_feed(self):
return self.title

def get_context(self, context):
if context.main_section == None:
context.main_section = ''
context.main_section = get_html_content_based_on_type(self, 'main_section', self.content_type)

# if static page, get static content
if context.slideshow:


+ 12
- 1
frappe/website/js/web_form_class.js Ver arquivo

@@ -55,6 +55,8 @@ export default class WebForm {
df.default = query_params[df.fieldname];
}

df.is_web_form = true;

delete df.parent;
delete df.parentfield;
delete df.parenttype;
@@ -76,6 +78,7 @@ export default class WebForm {
this.field_group.set_values(doc);
}

// show imag previews
setTimeout(() => {
this.field_group.fields_list.forEach((field_instance) => {
let instance_value = field_instance.value;
@@ -84,6 +87,14 @@ export default class WebForm {
}
});
}, 500);

// call the onload method first time, if defined
if (!this.loaded_flag) {
if (this.onload) {
this.onload();
}
this.loaded_flag = true;
}
}

get_values() {
@@ -112,7 +123,7 @@ export default class WebForm {
}

get_value(fieldname) {
return this.fieldname.get_value(fieldname);
return this.get_field(fieldname).get_value();
}

set_value(fieldname, value) {


+ 5
- 0
frappe/website/router.py Ver arquivo

@@ -293,6 +293,11 @@ def load_properties(page_info):

custom_base_template = extract_comment_tag(page_info.source, 'base_template')

page_info.meta_tags = frappe._dict()

page_info.meta_tags.name = extract_comment_tag(page_info.source, 'meta:name')
page_info.meta_tags.description = extract_comment_tag(page_info.source, 'meta:description')

if custom_base_template:
page_info.source = '''{{% extends "{0}" %}}
{{% block page_content %}}{1}{{% endblock %}}'''.format(custom_base_template, page_info.source)


+ 16
- 0
frappe/website/utils.py Ver arquivo

@@ -6,6 +6,7 @@ import functools
import frappe, re, os
from six import iteritems
from past.builtins import cmp
from frappe.utils import markdown

def delete_page_cache(path):
cache = frappe.cache()
@@ -327,3 +328,18 @@ def add_missing_headers():
content = '# {0}\n\n'.format(h) + content
f.write(content.encode('utf-8'))

def get_html_content_based_on_type(doc, fieldname, content_type):
'''
Set content based on content_type
'''
content = doc.get(fieldname)

if content_type == 'Markdown':
content = markdown(doc.get(fieldname + '_md'))
elif content_type == 'HTML':
content = doc.get(fieldname + '_html')

if content == None:
content = ''

return content

+ 3
- 0
frappe/website/website_generator.py Ver arquivo

@@ -36,6 +36,9 @@ class WebsiteGenerator(Document):
})

def validate(self):
self.set_route()

def set_route(self):
if self.is_website_published() and not self.route:
self.route = self.make_route()



Carregando…
Cancelar
Salvar