diff --git a/frappe/cli.py b/frappe/cli.py index 5d48cdedcb..a59945c25c 100755 --- a/frappe/cli.py +++ b/frappe/cli.py @@ -407,7 +407,6 @@ def latest(rebuild_website=True, quiet=False): import frappe.model.sync from frappe.utils.fixtures import sync_fixtures import frappe.translate - from frappe.website import statics verbose = not quiet @@ -421,11 +420,6 @@ def latest(rebuild_website=True, quiet=False): frappe.translate.clear_cache() sync_fixtures() - sync = statics.sync() - sync.start() - sync.start(rebuild=True) - # build website config if any changes in templates etc. - if rebuild_website: build_website() finally: diff --git a/frappe/patches.txt b/frappe/patches.txt index 201feac005..ad0ae5f54f 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -42,4 +42,4 @@ execute:frappe.reset_perms("User") #2014-06-13 execute:frappe.db.sql("""delete from `tabUserRole` where ifnull(parentfield, '')=''""") #2014-06-17 frappe.patches.v4_0.remove_user_owner_custom_field execute:frappe.delete_doc("DocType", "Website Template") -execute:frappe.get_attr("frappe.website.sync.sync")() #2014-06-17 +execute:frappe.reload_doc('website', 'doctype', 'website_route') #2014-06-17 diff --git a/frappe/website/statics.py b/frappe/website/statics.py index 1c4f53076a..228bc2a57c 100644 --- a/frappe/website/statics.py +++ b/frappe/website/statics.py @@ -182,6 +182,10 @@ class sync(object): where ifnull(static_file_timestamp,'')!='' order by (rgt-lft) asc""")) +def delete_static_web_pages(): + for name in frappe.db.sql_list("""select docname from `tabWebsite Route` + where ifnull(static_file_timestamp,'')!=''"""): + frappe.db.sql("delete from `tabWeb Page` where name=%s", name) def get_static_content(fpath, docname, route): d = frappe._dict({}) diff --git a/frappe/website/sync.py b/frappe/website/sync.py index 5eda7dffde..eb61327b6e 100644 --- a/frappe/website/sync.py +++ b/frappe/website/sync.py @@ -4,19 +4,37 @@ from __future__ import unicode_literals import frappe, os from frappe.modules import load_doctype_module +import statics, render def sync(app=None): if app: apps = [app] else: apps = frappe.get_installed_apps() - # delete all routes (resetting) - frappe.db.sql("delete from `tabWebsite Route`") + + print "Resetting..." + render.clear_cache() + + # delete all static web pages + statics.delete_static_web_pages() + + # delete all routes (resetting) + frappe.db.sql("delete from `tabWebsite Route`") for app in apps: + print "Importing pages from " + app sync_pages(app) + print "Importing generators from " + app sync_generators(app) + # sync statics + print "Importing statics" + statics_sync = statics.sync() + statics_sync.start() + + # rebuild for new inserts + statics_sync.start(rebuild=True) + def sync_pages(app): app_path = frappe.get_app_path(app) @@ -50,4 +68,6 @@ def sync_generators(app): order_by = "{0} {1}".format(module.sort_by, module.sort_order) for name in frappe.db.sql_list("select name from `tab{0}` {1} order by {2}".format(doctype, condition, order_by)): - frappe.get_doc(doctype, name).save(ignore_permissions=True) + doc = frappe.get_doc(doctype, name) + print doctype, name + doc.save(ignore_permissions=True)