added patch
This commit is contained in:
parent
96bf0b7f53
commit
40182bada3
11
erpnext/patches/june_2012/cms2.py
Normal file
11
erpnext/patches/june_2012/cms2.py
Normal file
@ -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()
|
@ -1,4 +1,7 @@
|
||||
{% extends "index.html" %}
|
||||
{% extends "outer.html" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
@ -28,7 +31,9 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
wrapper.blog_list = new wn.ui.Listing({
|
||||
|
||||
// if not a specific blog, show listing
|
||||
erpnext.blog_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('#blog-list').get(0),
|
||||
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
|
||||
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
|
||||
@ -49,5 +54,5 @@ wrapper.blog_list = new wn.ui.Listing({
|
||||
},
|
||||
page_length: 10
|
||||
});
|
||||
wrapper.blog_list.run();
|
||||
erpnext.blog_list.run();
|
||||
</script>
|
@ -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]
|
||||
@ -48,20 +51,30 @@ def get_html():
|
||||
webnotes.form_dict[key] = webnotes.form.getvalue(key)
|
||||
webnotes.connect()
|
||||
|
||||
# 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]
|
||||
|
||||
#try:
|
||||
page_name = get_page_by_short_name(page_name)
|
||||
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')
|
||||
|
||||
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: %s -->' % page_name)
|
||||
|
||||
except Exception, e:
|
||||
return jenv.get_template('404.html').render(get_outer_env()) + \
|
||||
('\n<!-- error: %s -->' % webnotes.getTraceback())
|
||||
|
||||
if __name__=="__main__":
|
||||
print "Content-Type: text/html"
|
||||
|
Loading…
x
Reference in New Issue
Block a user