blob: 88e70496ed559b7d6cc4fdf36b5f388c90717f4e [file] [log] [blame]
Rushabh Mehta40182ba2012-06-19 14:15:13 +05301def execute():
2 import webnotes
Rushabh Mehta40182ba2012-06-19 14:15:13 +05303 import webnotes.model.sync
4
Anand Doshi72c945b2012-06-22 20:01:07 +05305 # sync web page, blog doctype
Rushabh Mehta40182ba2012-06-19 14:15:13 +05306 webnotes.model.sync.sync('website', 'web_page')
Anand Doshi72c945b2012-06-22 20:01:07 +05307 webnotes.model.sync.sync('website', 'blog')
8
9 cleanup()
10
11 save_pages()
Rushabh Mehta40182ba2012-06-19 14:15:13 +053012
Anand Doshi72c945b2012-06-22 20:01:07 +053013def cleanup():
14 import webnotes
15
16 # delete pages from `tabPage` of module Website or of type Webpage
17 webnotes.conn.sql("""\
18 delete from `tabPage`
19 where module='Website' and ifnull(web_page, 'No') = 'Yes'""")
20
21def save_pages():
22 """save all web pages, blogs to create content"""
23 import webnotes
24 from webnotes.model.doclist import DocList
25 save_list = [
26 {
27 'doctype': 'Web Page',
28 'query': """select name from `tabWeb Page` where docstatus=0"""
29 },
30 {
31 'doctype': 'Blog',
32 'query': """\
33 select name from `tabBlog`
34 where docstatus = 0 and ifnull(published, 0) = 1"""
35 },
36 ]
37
38 for s in save_list:
39 for p in webnotes.conn.sql(s['query'], as_dict=1):
40 DocList(s['doctype'], p['name']).save()