From 1d64cd32fb868559abc8623cbc2f4b207d0b62c6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 7 Feb 2014 19:34:08 +0530 Subject: [PATCH] Call render_blocks automatically --- webnotes/__init__.py | 3 ++- .../doctype/communication/communication.py | 2 +- webnotes/core/doctype/profile/profile.py | 2 ++ webnotes/templates/generators/blog_post.py | 6 ++--- webnotes/templates/generators/web_page.py | 5 ++-- .../templates/generators/website_group.html | 9 +------- .../templates/generators/website_group.py | 4 ++-- webnotes/templates/includes/breadcrumbs.html | 8 +++++++ webnotes/templates/includes/sidebar.html | 4 ++-- webnotes/templates/pages/404.py | 8 ------- webnotes/templates/pages/about.py | 8 +------ webnotes/templates/pages/app.html | 4 ++-- webnotes/templates/pages/blog.py | 5 +--- webnotes/templates/pages/contact.py | 6 +---- webnotes/templates/pages/error.py | 6 +---- webnotes/templates/pages/login.py | 5 ---- webnotes/templates/pages/message.py | 4 +--- webnotes/templates/pages/update_password.py | 6 ----- webnotes/templates/pages/writers.py | 4 +--- webnotes/translate.py | 3 ++- webnotes/webutils.py | 23 +++++++++++++++---- 21 files changed, 50 insertions(+), 75 deletions(-) create mode 100644 webnotes/templates/includes/breadcrumbs.html delete mode 100644 webnotes/templates/pages/login.py diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 35ee5b44f1..ba32c471f5 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -563,7 +563,8 @@ def get_jenv(): jenv.globals.update({ "webnotes": sys.modules[__name__], - "webnotes.utils": webnotes.utils + "webnotes.utils": webnotes.utils, + "_": _ }) return jenv diff --git a/webnotes/core/doctype/communication/communication.py b/webnotes/core/doctype/communication/communication.py index def068ba59..afc2e72d3d 100644 --- a/webnotes/core/doctype/communication/communication.py +++ b/webnotes/core/doctype/communication/communication.py @@ -12,7 +12,7 @@ from webnotes.utils.email_lib.email_body import get_email from webnotes.utils.email_lib.smtp import send class DocType(): - def __init__(self, doc, doclist=[]): + def __init__(self, doc, doclist=None): self.doc = doc self.doclist = doclist diff --git a/webnotes/core/doctype/profile/profile.py b/webnotes/core/doctype/profile/profile.py index e39cf97830..4b1216aa53 100644 --- a/webnotes/core/doctype/profile/profile.py +++ b/webnotes/core/doctype/profile/profile.py @@ -305,6 +305,8 @@ def update_password(new_password, key=None, old_password=None): webnotes.conn.set_value("Profile", user, "reset_password_key", "") + webnotes.local.login_manager.logout() + return _("Password Updated") @webnotes.whitelist(allow_guest=True) diff --git a/webnotes/templates/generators/blog_post.py b/webnotes/templates/generators/blog_post.py index 44355c9c41..8d0fe2e554 100644 --- a/webnotes/templates/generators/blog_post.py +++ b/webnotes/templates/generators/blog_post.py @@ -6,13 +6,12 @@ from __future__ import unicode_literals import markdown2 import webnotes from webnotes.utils import global_date_format, get_fullname, cint -from webnotes.webutils import render_blocks doctype = "Blog Post" condition_field = "published" def get_context(context): - blog_post = webnotes.doc(context.ref_doctype, context.docname) + blog_post = context.bean.doc # this is for double precaution. usually it wont reach this code if not published if not cint(blog_post.published): @@ -35,9 +34,8 @@ def get_context(context): from `tabComment` where comment_doctype="Blog Post" and comment_docname=%s order by creation""", (blog_post.name,), as_dict=1) or [] - blog_post.fields.update(context) - return render_blocks(blog_post.fields) + return blog_post.fields @webnotes.whitelist(allow_guest=True) def get_blog_list(start=0, by=None, category=None): diff --git a/webnotes/templates/generators/web_page.py b/webnotes/templates/generators/web_page.py index f724042e90..28d8bb4715 100644 --- a/webnotes/templates/generators/web_page.py +++ b/webnotes/templates/generators/web_page.py @@ -3,14 +3,13 @@ from __future__ import unicode_literals import webnotes -from webnotes.webutils import render_blocks from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow doctype = "Web Page" condition_field = "published" def get_context(context): - web_page = webnotes.bean(context.ref_doctype, context.docname) + web_page = context.bean if web_page.doc.slideshow: web_page.doc.fields.update(get_slideshow(web_page)) @@ -36,7 +35,7 @@ def get_context(context): web_page.doc.fields.update(context) - return render_blocks(web_page.doc.fields) + return web_page.doc.fields def get_breadcrumbs(web_page): breadcrumbs = [] diff --git a/webnotes/templates/generators/website_group.html b/webnotes/templates/generators/website_group.html index 8b49ca56b6..dbbed07c94 100644 --- a/webnotes/templates/generators/website_group.html +++ b/webnotes/templates/generators/website_group.html @@ -7,14 +7,7 @@ {%- endif -%} {% endblock %} -{% block breadcrumbs %} - -{% endblock %} +{% block breadcrumbs %}{% include "templates/includes/breadcrumbs.html" %}{% endblock %} {% block content %}