@@ -563,7 +563,8 @@ def get_jenv(): | |||||
jenv.globals.update({ | jenv.globals.update({ | ||||
"webnotes": sys.modules[__name__], | "webnotes": sys.modules[__name__], | ||||
"webnotes.utils": webnotes.utils | |||||
"webnotes.utils": webnotes.utils, | |||||
"_": _ | |||||
}) | }) | ||||
return jenv | return jenv | ||||
@@ -12,7 +12,7 @@ from webnotes.utils.email_lib.email_body import get_email | |||||
from webnotes.utils.email_lib.smtp import send | from webnotes.utils.email_lib.smtp import send | ||||
class DocType(): | class DocType(): | ||||
def __init__(self, doc, doclist=[]): | |||||
def __init__(self, doc, doclist=None): | |||||
self.doc = doc | self.doc = doc | ||||
self.doclist = doclist | self.doclist = doclist | ||||
@@ -305,6 +305,8 @@ def update_password(new_password, key=None, old_password=None): | |||||
webnotes.conn.set_value("Profile", user, "reset_password_key", "") | webnotes.conn.set_value("Profile", user, "reset_password_key", "") | ||||
webnotes.local.login_manager.logout() | |||||
return _("Password Updated") | return _("Password Updated") | ||||
@webnotes.whitelist(allow_guest=True) | @webnotes.whitelist(allow_guest=True) | ||||
@@ -6,13 +6,12 @@ from __future__ import unicode_literals | |||||
import markdown2 | import markdown2 | ||||
import webnotes | import webnotes | ||||
from webnotes.utils import global_date_format, get_fullname, cint | from webnotes.utils import global_date_format, get_fullname, cint | ||||
from webnotes.webutils import render_blocks | |||||
doctype = "Blog Post" | doctype = "Blog Post" | ||||
condition_field = "published" | condition_field = "published" | ||||
def get_context(context): | 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 | # this is for double precaution. usually it wont reach this code if not published | ||||
if not cint(blog_post.published): | if not cint(blog_post.published): | ||||
@@ -35,9 +34,8 @@ def get_context(context): | |||||
from `tabComment` where comment_doctype="Blog Post" | from `tabComment` where comment_doctype="Blog Post" | ||||
and comment_docname=%s order by creation""", (blog_post.name,), as_dict=1) or [] | 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) | @webnotes.whitelist(allow_guest=True) | ||||
def get_blog_list(start=0, by=None, category=None): | def get_blog_list(start=0, by=None, category=None): | ||||
@@ -3,14 +3,13 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import render_blocks | |||||
from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow | from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow | ||||
doctype = "Web Page" | doctype = "Web Page" | ||||
condition_field = "published" | condition_field = "published" | ||||
def get_context(context): | def get_context(context): | ||||
web_page = webnotes.bean(context.ref_doctype, context.docname) | |||||
web_page = context.bean | |||||
if web_page.doc.slideshow: | if web_page.doc.slideshow: | ||||
web_page.doc.fields.update(get_slideshow(web_page)) | web_page.doc.fields.update(get_slideshow(web_page)) | ||||
@@ -36,7 +35,7 @@ def get_context(context): | |||||
web_page.doc.fields.update(context) | web_page.doc.fields.update(context) | ||||
return render_blocks(web_page.doc.fields) | |||||
return web_page.doc.fields | |||||
def get_breadcrumbs(web_page): | def get_breadcrumbs(web_page): | ||||
breadcrumbs = [] | breadcrumbs = [] | ||||
@@ -7,14 +7,7 @@ | |||||
{%- endif -%} | {%- endif -%} | ||||
{% endblock %} | {% endblock %} | ||||
{% block breadcrumbs %} | |||||
<ul class="breadcrumb"> | |||||
{% for parent in parents %} | |||||
<li><a href="/{{ parent.name|lower }}">{{ parent.page_title }}</a></li> | |||||
{% endfor %} | |||||
<li class="active">{{ title }}</li> | |||||
</ul> | |||||
{% endblock %} | |||||
{% block breadcrumbs %}{% include "templates/includes/breadcrumbs.html" %}{% endblock %} | |||||
{% block content %} | {% block content %} | ||||
<ul class="nav nav-tabs view-selector"> | <ul class="nav nav-tabs view-selector"> | ||||
@@ -2,7 +2,7 @@ | |||||
# MIT License. See license.txt | # MIT License. See license.txt | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import get_access, render_blocks, can_cache | |||||
from webnotes.webutils import get_access, can_cache | |||||
from webnotes.templates.website_group.post import clear_post_cache | from webnotes.templates.website_group.post import clear_post_cache | ||||
doctype = "Website Group" | doctype = "Website Group" | ||||
@@ -20,7 +20,7 @@ def get_context(context): | |||||
group_context["access"] = get_access(group) | group_context["access"] = get_access(group) | ||||
group_context.update(context) | group_context.update(context) | ||||
return render_blocks(group_context) | |||||
return group_context | |||||
except webnotes.DoesNotExistError: | except webnotes.DoesNotExistError: | ||||
return { | return { | ||||
@@ -0,0 +1,8 @@ | |||||
{% if parents -%} | |||||
<ul class="breadcrumb"> | |||||
{% for parent in parents %} | |||||
<li><a href="/{{ parent.name|lower }}">{{ parent.page_title }}</a></li> | |||||
{% endfor %} | |||||
<li class="active">{{ title }}</li> | |||||
</ul> | |||||
{%- endif %} |
@@ -1,4 +1,4 @@ | |||||
{%- if children -%} | |||||
{% if children -%} | |||||
{%- for child in children -%} | {%- for child in children -%} | ||||
<div class="sidebar-item"> | <div class="sidebar-item"> | ||||
<a href="/{{ child.name|lower }}" class="no-decoration"> | <a href="/{{ child.name|lower }}" class="no-decoration"> | ||||
@@ -9,4 +9,4 @@ | |||||
</a> | </a> | ||||
</div> | </div> | ||||
{%- endfor -%} | {%- endfor -%} | ||||
{%- endif -%} | |||||
{%- endif %} |
@@ -1,12 +1,4 @@ | |||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors | ||||
# MIT License. See license.txt | # MIT License. See license.txt | ||||
from __future__ import unicode_literals | |||||
import webnotes | |||||
from webnotes.webutils import render_blocks | |||||
no_sitemap = 1 | no_sitemap = 1 | ||||
def get_context(context): | |||||
return render_blocks(context) |
@@ -3,12 +3,6 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import render_blocks | |||||
def get_context(context): | def get_context(context): | ||||
about_context = { | |||||
"obj": webnotes.bean("About Us Settings", "About Us Settings").get_controller() | |||||
} | |||||
about_context.update(context) | |||||
return render_blocks(about_context) | |||||
return { "obj": webnotes.bean("About Us Settings", "About Us Settings").get_controller() } |
@@ -14,7 +14,7 @@ | |||||
</div> | </div> | ||||
<footer></footer> | <footer></footer> | ||||
{% for include in include_css -%} | {% for include in include_css -%} | ||||
<link type="text/css" rel="stylesheet" href="{{ include }}"> | |||||
<link type="text/css" rel="stylesheet" href="{{ include | scrub_relative_url }}"> | |||||
{%- endfor -%} | {%- endfor -%} | ||||
<script type="text/javascript" src="/assets/webnotes/js/lib/jquery/jquery.min.js"></script> | <script type="text/javascript" src="/assets/webnotes/js/lib/jquery/jquery.min.js"></script> | ||||
<script type="text/javascript"> | <script type="text/javascript"> | ||||
@@ -24,6 +24,6 @@ | |||||
</script> | </script> | ||||
{% for include in include_js -%} | {% for include in include_js -%} | ||||
<script type="text/javascript" src="{{ include }}"></script> | |||||
<script type="text/javascript" src="{{ include | scrub_relative_url }}"></script> | |||||
{%- endfor -%} | {%- endfor -%} | ||||
</body> | </body> |
@@ -3,9 +3,6 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import render_blocks | |||||
def get_context(context): | def get_context(context): | ||||
blog_context = webnotes.doc("Blog Settings", "Blog Settings").fields | |||||
blog_context.update(context) | |||||
return render_blocks(blog_context) | |||||
return webnotes.doc("Blog Settings", "Blog Settings").fields |
@@ -5,7 +5,6 @@ from __future__ import unicode_literals | |||||
import webnotes | import webnotes | ||||
from webnotes.utils import now | from webnotes.utils import now | ||||
from webnotes.webutils import render_blocks | |||||
def get_context(context): | def get_context(context): | ||||
bean = webnotes.bean("Contact Us Settings", "Contact Us Settings") | bean = webnotes.bean("Contact Us Settings", "Contact Us Settings") | ||||
@@ -15,16 +14,13 @@ def get_context(context): | |||||
address = webnotes.bean("Address", bean.doc.address).doc if bean.doc.address else None | address = webnotes.bean("Address", bean.doc.address).doc if bean.doc.address else None | ||||
contact_context = { | |||||
return { | |||||
"query_options": query_options, | "query_options": query_options, | ||||
"address": address, | "address": address, | ||||
"heading": bean.doc.heading, | "heading": bean.doc.heading, | ||||
"introduction": bean.doc.introduction | "introduction": bean.doc.introduction | ||||
} | } | ||||
contact_context.update(context) | |||||
return render_blocks(contact_context) | |||||
max_communications_per_hour = 300 | max_communications_per_hour = 300 | ||||
@webnotes.whitelist(allow_guest=True) | @webnotes.whitelist(allow_guest=True) | ||||
@@ -3,13 +3,9 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import render_blocks | |||||
no_cache = 1 | no_cache = 1 | ||||
no_sitemap = 1 | no_sitemap = 1 | ||||
def get_context(context): | def get_context(context): | ||||
error_context = {"error": webnotes.get_traceback()} | |||||
error_context.update(context) | |||||
return render_blocks(error_context) | |||||
return {"error": webnotes.get_traceback()} |
@@ -1,5 +0,0 @@ | |||||
import webnotes | |||||
from webnotes.webutils import render_blocks | |||||
def get_context(context): | |||||
return render_blocks(context) |
@@ -3,7 +3,6 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import render_blocks | |||||
no_cache = 1 | no_cache = 1 | ||||
no_sitemap = 1 | no_sitemap = 1 | ||||
@@ -16,5 +15,4 @@ def get_context(context): | |||||
if hasattr(webnotes.local, "message_success"): | if hasattr(webnotes.local, "message_success"): | ||||
message_context["success"] = webnotes.local.message_success | message_context["success"] = webnotes.local.message_success | ||||
message_context.update(context) | |||||
return render_blocks(message_context) | |||||
return message_context |
@@ -1,10 +1,4 @@ | |||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors | ||||
# MIT License. See license.txt | # MIT License. See license.txt | ||||
from __future__ import unicode_literals | |||||
from webnotes.webutils import render_blocks | |||||
no_sitemap = 1 | no_sitemap = 1 | ||||
def get_context(context): | |||||
return render_blocks(context) |
@@ -3,7 +3,6 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import webnotes | import webnotes | ||||
from webnotes.webutils import render_blocks | |||||
def get_context(context): | def get_context(context): | ||||
bloggers = webnotes.conn.sql("""select * from `tabBlogger` | bloggers = webnotes.conn.sql("""select * from `tabBlogger` | ||||
@@ -19,6 +18,5 @@ def get_context(context): | |||||
} | } | ||||
writers_context.update(webnotes.doc("Blog Settings", "Blog Settings").fields) | writers_context.update(webnotes.doc("Blog Settings", "Blog Settings").fields) | ||||
writers_context.update(context) | |||||
return render_blocks(writers_context) | |||||
return writers_context |
@@ -21,7 +21,8 @@ import webnotes, os, re, codecs, json | |||||
def get_user_lang(user=None): | def get_user_lang(user=None): | ||||
if not user: | if not user: | ||||
user = webnotes.session.user | user = webnotes.session.user | ||||
return get_lang_dict().get(webnotes.conn.get_value("Profile", user, "language") or "english") | |||||
user_lang = webnotes.conn.get_value("Profile", user, "language") | |||||
return get_lang_dict().get(user_lang!="Loading..." and user_lang or "english") | |||||
def get_all_languages(): | def get_all_languages(): | ||||
return [a.split()[0] for a in get_lang_info()] | return [a.split()[0] for a in get_lang_info()] | ||||
@@ -128,6 +128,9 @@ def build_sitemap_options(page_name): | |||||
"page_name_field", "condition_field"): | "page_name_field", "condition_field"): | ||||
sitemap_options[fieldname] = sitemap_config.get(fieldname) | sitemap_options[fieldname] = sitemap_config.get(fieldname) | ||||
sitemap_options.doctype = sitemap_options.ref_doctype | |||||
sitemap_options.title = sitemap_options.page_title | |||||
# establish hierarchy | # establish hierarchy | ||||
sitemap_options.parents = webnotes.conn.sql("""select name, page_title from `tabWebsite Sitemap` | sitemap_options.parents = webnotes.conn.sql("""select name, page_title from `tabWebsite Sitemap` | ||||
where lft < %s and rgt > %s order by lft asc""", (sitemap_options.lft, sitemap_options.rgt), as_dict=True) | where lft < %s and rgt > %s order by lft asc""", (sitemap_options.lft, sitemap_options.rgt), as_dict=True) | ||||
@@ -143,14 +146,24 @@ def build_sitemap_options(page_name): | |||||
def build_context(sitemap_options): | def build_context(sitemap_options): | ||||
"""get_context method of bean or module is supposed to render content templates and push it into context""" | """get_context method of bean or module is supposed to render content templates and push it into context""" | ||||
context = webnotes._dict({ "_": webnotes._ }) | |||||
context.update(sitemap_options) | |||||
context = webnotes._dict(sitemap_options) | |||||
context.update(get_website_settings()) | context.update(get_website_settings()) | ||||
if sitemap_options.get("controller"): | |||||
module = webnotes.get_module(sitemap_options.get("controller")) | |||||
# provide bean | |||||
if context.doctype and context.docname: | |||||
context.bean = webnotes.bean(context.doctype, context.docname) | |||||
if context.controller: | |||||
module = webnotes.get_module(context.controller) | |||||
if module and hasattr(module, "get_context"): | if module and hasattr(module, "get_context"): | ||||
context.data = module.get_context(context) or {} | |||||
context.update(module.get_context(context) or {}) | |||||
if context.get("base_template_path") != context.get("template_path") and not context.get("rendered"): | |||||
context.data = render_blocks(context) | |||||
# remove bean, as it is not pickle friendly and its purpose is over | |||||
if context.bean: | |||||
del context["bean"] | |||||
return context | return context | ||||