fixes for statics -> statics will be built after fixtures

This commit is contained in:
Rushabh Mehta 2014-06-17 16:36:32 +05:30
parent a2aaba7d9e
commit 5c3ba2edd1
4 changed files with 28 additions and 10 deletions

View file

@ -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:

View file

@ -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

View file

@ -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({})

View file

@ -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)