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 %}
|
{% block content %}
|
||||||
<div class="layout-wrapper layout-wrapper-background">
|
<div class="layout-wrapper layout-wrapper-background">
|
||||||
@ -28,7 +31,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<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),
|
parent: $(wrapper).find('#blog-list').get(0),
|
||||||
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
|
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
|
||||||
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
|
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
|
page_length: 10
|
||||||
});
|
});
|
||||||
wrapper.blog_list.run();
|
erpnext.blog_list.run();
|
||||||
</script>
|
</script>
|
@ -17,6 +17,9 @@ sys.path.append(conf.modules_path)
|
|||||||
|
|
||||||
def get_outer_env():
|
def get_outer_env():
|
||||||
"""env for outer (cache this)"""
|
"""env for outer (cache this)"""
|
||||||
|
|
||||||
|
# TODO: Cache this in cache item
|
||||||
|
|
||||||
import webnotes
|
import webnotes
|
||||||
return {
|
return {
|
||||||
'top_bar_items': webnotes.conn.sql("""select * from `tabTop Bar Item`
|
'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'),
|
'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"""
|
"""get page by shortname"""
|
||||||
import webnotes
|
import webnotes
|
||||||
return webnotes.conn.sql("""select name from `tabWeb Page` where page_name=%s""", page_name)[0][0]
|
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.form_dict[key] = webnotes.form.getvalue(key)
|
||||||
webnotes.connect()
|
webnotes.connect()
|
||||||
|
|
||||||
if 'page' in webnotes.form_dict:
|
# Get web page
|
||||||
page_name = webnotes.form_dict['page']
|
try:
|
||||||
if page_name.endswith('.html'):
|
if 'page' in webnotes.form_dict:
|
||||||
page_name = page_name[:-5]
|
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 = Document('Web Page', page_name)
|
||||||
page.fields.update(get_outer_env())
|
page.fields.update(get_outer_env())
|
||||||
return jenv.get_template('page.html').render(page.fields)
|
return jenv.get_template('page.html').render(page.fields) + \
|
||||||
#except Exception, e:
|
('\n<!-- page: %s -->' % page_name)
|
||||||
# return jenv.get_template('404.html').render(get_outer_env())
|
|
||||||
else:
|
except Exception, e:
|
||||||
return jenv.get_template('404.html').render(get_outer_env())
|
return jenv.get_template('404.html').render(get_outer_env()) + \
|
||||||
|
('\n<!-- error: %s -->' % webnotes.getTraceback())
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
print "Content-Type: text/html"
|
print "Content-Type: text/html"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user