parent
10106ed065
commit
bb0f8b3e05
1 changed files with 9 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import frappe
|
||||
from frappe.model.base_document import get_controller
|
||||
|
||||
def execute():
|
||||
update_routes(['Blog Post', 'Blog Category', 'Web Page'])
|
||||
|
|
@ -7,8 +8,15 @@ def update_routes(doctypes):
|
|||
"""Patch old routing system"""
|
||||
for d in doctypes:
|
||||
frappe.reload_doctype(d)
|
||||
c = get_controller(d)
|
||||
|
||||
condition = ''
|
||||
if c.website.condition_field:
|
||||
condition = 'where {0}=1'.format(c.website.condition_field)
|
||||
|
||||
try:
|
||||
frappe.db.sql("""update `tab{0}` set route = concat(ifnull(parent_website_route, ""),
|
||||
if(ifnull(parent_website_route, "")="", "", "/"), page_name)""".format(d))
|
||||
if(ifnull(parent_website_route, "")="", "", "/"), page_name) {1}""".format(d, condition))
|
||||
|
||||
except Exception, e:
|
||||
if e.args[0]!=1054: raise e
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue