From 40182bada34fdec6c8c88567493a7f3fb85b07c7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 19 Jun 2012 14:15:13 +0530 Subject: [PATCH] added patch --- erpnext/patches/june_2012/cms2.py | 11 ++++++++ erpnext/website/templates/blog.html | 11 +++++--- public/web.py | 39 +++++++++++++++++++---------- 3 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 erpnext/patches/june_2012/cms2.py diff --git a/erpnext/patches/june_2012/cms2.py b/erpnext/patches/june_2012/cms2.py new file mode 100644 index 0000000000..fb9c72cf55 --- /dev/null +++ b/erpnext/patches/june_2012/cms2.py @@ -0,0 +1,11 @@ +def execute(): + import webnotes + from webnotes.model.doclist import DocList + import webnotes.model.sync + + # sync web page doctype + webnotes.model.sync.sync('website', 'web_page') + + # save all web pages to create content + for p in webnotes.conn.sql("""select name from `tabWeb Page` where docstatus=0"""): + DocList('Web Page', p[0]).save() \ No newline at end of file diff --git a/erpnext/website/templates/blog.html b/erpnext/website/templates/blog.html index 30dbd3b87e..d0b9a1362b 100644 --- a/erpnext/website/templates/blog.html +++ b/erpnext/website/templates/blog.html @@ -1,4 +1,7 @@ -{% extends "index.html" %} +{% extends "outer.html" %} + +{% block title %}{{ title }}{% endblock %} + {% block content %}
@@ -28,7 +31,9 @@
\ No newline at end of file diff --git a/public/web.py b/public/web.py index 8909bf2f82..c7c1df2109 100755 --- a/public/web.py +++ b/public/web.py @@ -17,6 +17,9 @@ sys.path.append(conf.modules_path) def get_outer_env(): """env for outer (cache this)""" + + # TODO: Cache this in cache item + import webnotes return { 'top_bar_items': webnotes.conn.sql("""select * from `tabTop Bar Item` @@ -31,7 +34,7 @@ def get_outer_env(): 'copyright': webnotes.conn.get_value('Website Settings', None, 'copyright'), } -def get_page_by_short_name(page_name): +def get_web_page_name(page_name): """get page by shortname""" import webnotes return webnotes.conn.sql("""select name from `tabWeb Page` where page_name=%s""", page_name)[0][0] @@ -47,21 +50,31 @@ def get_html(): for key in webnotes.form.keys(): webnotes.form_dict[key] = webnotes.form.getvalue(key) webnotes.connect() - - if 'page' in webnotes.form_dict: - page_name = webnotes.form_dict['page'] - if page_name.endswith('.html'): - page_name = page_name[:-5] + + # Get web page + try: + if 'page' in webnotes.form_dict: + page_name = webnotes.form_dict['page'] + if page_name.endswith('.html'): + page_name = page_name[:-5] + + if page_name.startswith('blog'): + pass + # page_name = + else: + page_name = get_web_page_name(page_name) + else: + from webnotes.cms import get_home_page + page_name = get_home_page('Guest') - #try: - page_name = get_page_by_short_name(page_name) page = Document('Web Page', page_name) page.fields.update(get_outer_env()) - return jenv.get_template('page.html').render(page.fields) - #except Exception, e: - # return jenv.get_template('404.html').render(get_outer_env()) - else: - return jenv.get_template('404.html').render(get_outer_env()) + return jenv.get_template('page.html').render(page.fields) + \ + ('\n' % page_name) + + except Exception, e: + return jenv.get_template('404.html').render(get_outer_env()) + \ + ('\n' % webnotes.getTraceback()) if __name__=="__main__": print "Content-Type: text/html"