mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 19:29:10 +00:00
template based web page loading using web.py
This commit is contained in:
@@ -1,11 +1,40 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.model.doclist import DocList
|
||||
import webnotes.model.sync
|
||||
|
||||
# sync web page doctype
|
||||
# sync web page, blog doctype
|
||||
webnotes.model.sync.sync('website', 'web_page')
|
||||
webnotes.model.sync.sync('website', 'blog')
|
||||
|
||||
cleanup()
|
||||
|
||||
save_pages()
|
||||
|
||||
# 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()
|
||||
def cleanup():
|
||||
import webnotes
|
||||
|
||||
# delete pages from `tabPage` of module Website or of type Webpage
|
||||
webnotes.conn.sql("""\
|
||||
delete from `tabPage`
|
||||
where module='Website' and ifnull(web_page, 'No') = 'Yes'""")
|
||||
|
||||
def save_pages():
|
||||
"""save all web pages, blogs to create content"""
|
||||
import webnotes
|
||||
from webnotes.model.doclist import DocList
|
||||
save_list = [
|
||||
{
|
||||
'doctype': 'Web Page',
|
||||
'query': """select name from `tabWeb Page` where docstatus=0"""
|
||||
},
|
||||
{
|
||||
'doctype': 'Blog',
|
||||
'query': """\
|
||||
select name from `tabBlog`
|
||||
where docstatus = 0 and ifnull(published, 0) = 1"""
|
||||
},
|
||||
]
|
||||
|
||||
for s in save_list:
|
||||
for p in webnotes.conn.sql(s['query'], as_dict=1):
|
||||
DocList(s['doctype'], p['name']).save()
|
||||
Reference in New Issue
Block a user