@@ -33,9 +33,10 @@ cur_frm.cscript.onload = function(doc, dt, dn) { | |||||
cur_frm.cscript.refresh = function(doc, dt, dn) { | cur_frm.cscript.refresh = function(doc, dt, dn) { | ||||
//console.log(p) | //console.log(p) | ||||
$(cur_frm.frm_head.timestamp_area).toggle(false); | |||||
$(cur_frm.frm_head.page_head.buttons.Save).toggle(false); | |||||
$(cur_frm.page_layout.footer).toggle(false); | |||||
//$(cur_frm.frm_head.timestamp_area).toggle(false); | |||||
//$(cur_frm.frm_head.page_head.buttons.Save).toggle(false); | |||||
//$(cur_frm.page_layout.footer).toggle(false); | |||||
cur_frm.frm_head.appframe.clear_buttons(); | |||||
cur_frm.add_custom_button('Update', function() { | cur_frm.add_custom_button('Update', function() { | ||||
if(cur_frm.fields_dict['doc_type'].value) { | if(cur_frm.fields_dict['doc_type'].value) { | ||||
@@ -43,17 +44,17 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { | |||||
if(r.exc) { | if(r.exc) { | ||||
msgprint(r.exc); | msgprint(r.exc); | ||||
} else { | } else { | ||||
wn.ui.toolbar.clear_cache(); | |||||
if(r.server_messages) { cur_frm.cscript.doc_type(doc, doc.doctype, doc.name); } | if(r.server_messages) { cur_frm.cscript.doc_type(doc, doc.doctype, doc.name); } | ||||
cur_frm.frm_head.status_area.innerHTML = | |||||
'<span style="padding: 2px; background-color: rgb(0, 170, 17); \ | |||||
color: rgb(255, 255, 255); font-weight: bold; margin-left: 0px; \ | |||||
font-size: 11px;">Saved</span>'; | |||||
this.$w.find('.label-area').html(repl('<span class="label %(lab_class)s">\ | |||||
%(lab_status)s</span>', { | |||||
lab_status: 'Saved', | |||||
lab_class: 'label-success' | |||||
})); | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
},1); | },1); | ||||
$(cur_frm.frm_head.page_head.buttons.Update).addClass('btn-info'); | |||||
//$(cur_frm.frm_head.page_head.buttons.Update).addClass('btn-info'); | |||||
cur_frm.add_custom_button('Refresh Form', function() { | cur_frm.add_custom_button('Refresh Form', function() { | ||||
cur_frm.cscript.doc_type(doc, dt, dn); | cur_frm.cscript.doc_type(doc, dt, dn); | ||||
@@ -65,10 +66,10 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { | |||||
}, 1); | }, 1); | ||||
if(!doc.doc_type) { | if(!doc.doc_type) { | ||||
var page_head = cur_frm.frm_head.page_head; | |||||
page_head.buttons['Update'].disabled = true; | |||||
page_head.buttons['Refresh Form'].disabled = true; | |||||
page_head.buttons['Reset to defaults'].disabled = true; | |||||
var frm_head = cur_frm.frm_head.appframe; | |||||
$(frm_head.buttons['Update']).attr('disabled', true); | |||||
$(frm_head.buttons['Refresh Form']).attr('disabled', true); | |||||
$(frm_head.buttons['Reset to defaults']).attr('disabled', true); | |||||
} | } | ||||
cur_frm.cscript.hide_allow_attach(doc, dt, dn); | cur_frm.cscript.hide_allow_attach(doc, dt, dn); | ||||
@@ -119,7 +120,6 @@ cur_frm.confirm = function(msg, doc, dt, dn) { | |||||
'<span style="padding: 2px; background-color: rgb(0, 170, 17); \ | '<span style="padding: 2px; background-color: rgb(0, 170, 17); \ | ||||
color: rgb(255, 255, 255); font-weight: bold; margin-left: 0px; \ | color: rgb(255, 255, 255); font-weight: bold; margin-left: 0px; \ | ||||
font-size: 11px;">Saved</span>'; | font-size: 11px;">Saved</span>'; | ||||
wn.ui.toolbar.clear_cache(); | |||||
} | } | ||||
}); | }); | ||||
}); | }); | ||||
@@ -79,9 +79,9 @@ class Installer: | |||||
# fresh app | # fresh app | ||||
if 'Framework.sql' in source_path: | if 'Framework.sql' in source_path: | ||||
from webnotes.model.sync import sync_core_doctypes | |||||
print "Building tables from core module..." | |||||
sync_core_doctypes() | |||||
from webnotes.model.sync import sync_install | |||||
print "Building tables from all module..." | |||||
sync_install() | |||||
# framework cleanups | # framework cleanups | ||||
self.framework_cleanups(target) | self.framework_cleanups(target) | ||||
@@ -94,7 +94,6 @@ class Installer: | |||||
import webnotes | import webnotes | ||||
self.create_sessions_table() | self.create_sessions_table() | ||||
self.create_scheduler_log() | self.create_scheduler_log() | ||||
self.create_doctype_cache() | |||||
self.create_session_cache() | self.create_session_cache() | ||||
self.create_cache_item() | self.create_cache_item() | ||||
@@ -127,15 +126,6 @@ class Installer: | |||||
error text | error text | ||||
) engine=MyISAM""") | ) engine=MyISAM""") | ||||
def create_doctype_cache(self): | |||||
import webnotes | |||||
self.dbman.drop_table('__DocTypeCache') | |||||
webnotes.conn.sql("""create table `__DocTypeCache` ( | |||||
name VARCHAR(120), | |||||
modified DATETIME, | |||||
content TEXT, | |||||
server_code_compiled TEXT)""") | |||||
def create_session_cache(self): | def create_session_cache(self): | ||||
import webnotes | import webnotes | ||||
self.dbman.drop_table('__SessionCache') | self.dbman.drop_table('__SessionCache') | ||||
@@ -5,19 +5,26 @@ | |||||
import webnotes | import webnotes | ||||
def sync_all(force=0): | def sync_all(force=0): | ||||
sync_core_doctypes(force) | |||||
sync_modules(force) | |||||
webnotes.conn.sql("DELETE FROM __CacheItem") | |||||
modules = [] | |||||
modules += sync_core_doctypes(force) | |||||
modules += sync_modules(force) | |||||
try: | |||||
webnotes.conn.begin() | |||||
webnotes.conn.sql("DELETE FROM __CacheItem") | |||||
webnotes.conn.commit() | |||||
except Exception, e: | |||||
if e[0]!=1146: raise e | |||||
return modules | |||||
def sync_core_doctypes(force=0): | def sync_core_doctypes(force=0): | ||||
import os | import os | ||||
import core | import core | ||||
# doctypes | # doctypes | ||||
walk_and_sync(os.path.abspath(os.path.dirname(core.__file__)), force) | |||||
return walk_and_sync(os.path.abspath(os.path.dirname(core.__file__)), force) | |||||
def sync_modules(force=0): | def sync_modules(force=0): | ||||
import conf | import conf | ||||
walk_and_sync(conf.modules_path, force) | |||||
return walk_and_sync(conf.modules_path, force) | |||||
def walk_and_sync(start_path, force=0): | def walk_and_sync(start_path, force=0): | ||||
"""walk and sync all doctypes and pages""" | """walk and sync all doctypes and pages""" | ||||
@@ -46,9 +53,7 @@ def walk_and_sync(start_path, force=0): | |||||
reload_doc(module_name, 'page', name) | reload_doc(module_name, 'page', name) | ||||
print module_name + ' | ' + doctype + ' | ' + name | print module_name + ' | ' + doctype + ' | ' + name | ||||
# load install docs | |||||
load_install_docs(modules) | |||||
return modules | |||||
# docname in small letters with underscores | # docname in small letters with underscores | ||||
@@ -124,6 +129,13 @@ def save_perms_if_none_exist(doclist): | |||||
if d.get('doctype') != 'DocPerm': continue | if d.get('doctype') != 'DocPerm': continue | ||||
Document(fielddata=d).save(1, check_links=0, ignore_fields=1) | Document(fielddata=d).save(1, check_links=0, ignore_fields=1) | ||||
def sync_install(force=1): | |||||
# sync all doctypes | |||||
modules = sync_all(force) | |||||
# load install docs | |||||
load_install_docs(modules) | |||||
def load_install_docs(modules): | def load_install_docs(modules): | ||||
import os | import os | ||||
if isinstance(modules, basestring): modules = [modules] | if isinstance(modules, basestring): modules = [modules] | ||||
@@ -130,4 +130,4 @@ def get_search_criteria(dt): | |||||
for sc in sc_list: | for sc in sc_list: | ||||
if sc[0]: | if sc[0]: | ||||
dl += webnotes.model.doc.get('Search Criteria', sc[0]) | dl += webnotes.model.doc.get('Search Criteria', sc[0]) | ||||
return dl | |||||
return dl |