diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index e8871b681b..a3f7aca40d 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -58,6 +58,7 @@ class DocType(Document): validate_permissions(self) self.make_amendable() + self.validate_website() def check_developer_mode(self): """Throw exception if not developer mode or via patch""" @@ -73,6 +74,18 @@ class DocType(Document): if self.document_type=="Master": self.document_type = "Setup" + def validate_website(self): + """Ensure that website generator has field 'route'""" + from frappe.model.base_document import get_controller + try: + controller = get_controller(self.name) + except: + controller = None + + if controller and controller.website: + if not 'route' in [d.fieldname for d in self.fields]: + frappe.throw('Field "route" is mandatory for Website Generator pages', title='Missing Field') + def change_modified_of_parent(self): """Change the timestamp of parent DocType if the current one is a child to clear caches.""" if frappe.flags.in_import: diff --git a/frappe/public/js/legacy/form.js b/frappe/public/js/legacy/form.js index 2ac064861a..6a55f2cef7 100644 --- a/frappe/public/js/legacy/form.js +++ b/frappe/public/js/legacy/form.js @@ -365,7 +365,7 @@ _f.Frm.prototype.show_web_link = function() { _f.Frm.prototype.add_web_link = function(path) { this.web_link = this.sidebar.add_user_action("See on Website", - function() {}).attr("href", path).attr("target", "_blank"); + function() {}).attr("href", this.doc.route).attr("target", "_blank"); } _f.Frm.prototype.check_doc_perm = function() { diff --git a/frappe/templates/generators/blog_post.html b/frappe/templates/generators/blog_post.html index b2c8079141..45786de49f 100644 --- a/frappe/templates/generators/blog_post.html +++ b/frappe/templates/generators/blog_post.html @@ -11,7 +11,7 @@
By {{ blogger_info and blogger_info.full_name or full_name }} {{ frappe.format_date(published_on) }} - {{ blog_category }} + {{ category.title }} {{ comment_text }}
diff --git a/frappe/templates/includes/blog/blog_row.html b/frappe/templates/includes/blog/blog_row.html index 897a640a4f..6861e7f668 100644 --- a/frappe/templates/includes/blog/blog_row.html +++ b/frappe/templates/includes/blog/blog_row.html @@ -8,7 +8,7 @@ By {{ post.full_name }} {{ frappe.format_date(post.published_on) }} - {{ post.blog_category }} + {{ post.category.title }} {{ post.comment_text }} diff --git a/frappe/templates/includes/search_box.html b/frappe/templates/includes/search_box.html index 5e94ee62f3..32c2cb9733 100644 --- a/frappe/templates/includes/search_box.html +++ b/frappe/templates/includes/search_box.html @@ -1,39 +1,37 @@-
+ ++