From 4e4b9197d2153f99166d098fb4b16e2fd18fad94 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 27 Feb 2014 13:11:23 +0530 Subject: [PATCH] 3to4 fixes --- frappe/modules/__init__.py | 2 +- frappe/patches/4_0/rename_sitemap_to_route.py | 20 +++++++++++-------- frappe/patches/4_0/set_website_route_idx.py | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/frappe/modules/__init__.py b/frappe/modules/__init__.py index b310b448fe..edc71b717c 100644 --- a/frappe/modules/__init__.py +++ b/frappe/modules/__init__.py @@ -32,7 +32,7 @@ def get_doc_path(module, doctype, name): def reload_doc(module, dt=None, dn=None, force=True): from frappe.modules.import_file import import_files - return import_files(scrub(module), scrub(dt), scrub(dn), force=force) + return import_files(module, dt, dn, force=force) def export_doc(doctype, name, module=None): """write out a doc""" diff --git a/frappe/patches/4_0/rename_sitemap_to_route.py b/frappe/patches/4_0/rename_sitemap_to_route.py index d99a2fd732..e3ed0bf1d0 100644 --- a/frappe/patches/4_0/rename_sitemap_to_route.py +++ b/frappe/patches/4_0/rename_sitemap_to_route.py @@ -10,14 +10,18 @@ def execute(): if "tabWebsite Template" not in tables: frappe.rename_doc("DocType", "Website Sitemap Config", "Website Template", force=True) - if "tabWebsite Route Permission" not in tables: - frappe.rename_doc("DocType", "Website Sitemap Permission", "Website Route Permission", force=True) + try: + if "tabWebsite Route Permission" not in tables: + frappe.rename_doc("DocType", "Website Sitemap Permission", "Website Route Permission", force=True) + for d in ("Blog Category", "Blog Post", "Web Page", "Website Route", "Website Group"): + rename_field(d, "parent_website_sitemap", "parent_website_route") + + rename_field("Website Route", "website_sitemap_config", "website_template") + rename_field("Website Route Permission", "website_sitemap", "website_route") + except Exception, e: + if e.args[0] != 1054: + raise + for d in ("blog_category", "blog_post", "web_page", "website_route", "website_group"): frappe.reload_doc("website", "doctype", d) - - for d in ("Blog Category", "Blog Post", "Web Page", "Website Route", "Website Group"): - rename_field(d, "parent_website_sitemap", "parent_website_route") - - rename_field("Website Route", "website_sitemap_config", "website_template") - rename_field("Website Route Permission", "website_sitemap", "website_route") diff --git a/frappe/patches/4_0/set_website_route_idx.py b/frappe/patches/4_0/set_website_route_idx.py index e001174bde..a19d89ea9e 100644 --- a/frappe/patches/4_0/set_website_route_idx.py +++ b/frappe/patches/4_0/set_website_route_idx.py @@ -13,7 +13,8 @@ def execute(): doctype = frappe.get_attr(get_template_controller(app, g["path"], g["fname"]) + ".doctype") module = frappe.db.get_value("DocType", doctype, "module") frappe.reload_doc(module, "doctype", doctype) - + + frappe.db.sql("""update `tabBlog Category` set `title`=`name` where ifnull(`title`, '')=''""") frappe.db.sql("""update `tabWebsite Route` set idx=null""") for doctype in ["Blog Category", "Blog Post", "Web Page", "Website Group"]: frappe.db.sql("""update `tab{}` set idx=null""".format(doctype))