From 3ee3a7ef4d01657227e7cc40e8696deaa6607f39 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 28 Jun 2011 21:10:05 +0530 Subject: [PATCH] form style and module fixes --- cgi-bin/webnotes/modules/__init__.py | 26 +++++++++++++++++++++- cgi-bin/webnotes/modules/module_manager.py | 24 -------------------- js/form.compressed.js | 2 +- js/widgets/form/form_container.js | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cgi-bin/webnotes/modules/__init__.py b/cgi-bin/webnotes/modules/__init__.py index 665c77013c..62efefc36a 100644 --- a/cgi-bin/webnotes/modules/__init__.py +++ b/cgi-bin/webnotes/modules/__init__.py @@ -62,4 +62,28 @@ def get_module_path(module): # get module path by importing the module modules_path = os.path.join(webnotes.defs.modules_path, scrub(module)) - return modules_path \ No newline at end of file + return modules_path + +def switch_module(dt, dn, to, frm=None, export=None): + """ + Change the module of the given doctype, if export is true, then also export txt and copy + code files from src + """ + import os + webnotes.conn.sql("update `tab"+dt+"` set module=%s where name=%s", (to, dn)) + + if export: + export_doc(dt, dn) + + # copy code files + if dt in ('DocType', 'Page', 'Search Criteria'): + from_path = os.path.join(get_module_path(frm), scrub(dt), scrub(dn), scrub(dn)) + to_path = os.path.join(get_module_path(to), scrub(dt), scrub(dn), scrub(dn)) + + # make dire if exists + os.system('mkdir -p %s' % os.path.join(get_module_path(to), scrub(dt), scrub(dn))) + + for ext in ('py','js','html','css'): + os.system('cp %s %s') + + diff --git a/cgi-bin/webnotes/modules/module_manager.py b/cgi-bin/webnotes/modules/module_manager.py index 90679df0b2..c166646bff 100644 --- a/cgi-bin/webnotes/modules/module_manager.py +++ b/cgi-bin/webnotes/modules/module_manager.py @@ -1,27 +1,3 @@ -#============================================================================== -# script to change the module name in the database & update svn -#============================================================================== - -def change_module(dt, dn, from_module, to_module): - import os, webnotes.defs - from webnotes.modules import scrub - - # change in db - webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % (dt, '%s', '%s'), (to_module, dn)) - - # export files - from webnotes.modules.export_module import export_to_files - export_to_files(record_list = [[dt, dn]]) - - if dt in ['DocType','Page','Search Criteria']: - dt, dn = scrub(dt), scrub(dn) - - # svn add - webnotes.msgprint(os.popen("svn add %s" % os.path.join(webnotes.defs.modules_path, scrub(to_module), dt, dn)).read()) - - # svn remove - webnotes.msgprint(os.popen("svn remove %s" % os.path.join(webnotes.defs.modules_path, scrub(from_module), dt, dn)).read()) - #============================================================================== diff --git a/js/form.compressed.js b/js/form.compressed.js index 3ebd877383..32c2369634 100644 --- a/js/form.compressed.js +++ b/js/form.compressed.js @@ -1,5 +1,5 @@ -_f.FrmContainer=function(){this.wrapper=page_body.add_page("Forms",function(){},function(){});this.last_displayed=null;$dh(this.wrapper);this.body=$a(this.wrapper,'div');_f.frm_dialog=new _f.FrmDialog();} +_f.FrmContainer=function(){this.wrapper=page_body.add_page("Forms",function(){},function(){});this.last_displayed=null;$dh(this.wrapper);this.body=$a(this.wrapper,'div','frm_container');_f.frm_dialog=new _f.FrmDialog();} _f.frm_dialog=null;_f.calling_doc_stack=[];_f.temp_access={};_f.FrmDialog=function(){var me=this;this.last_displayed=null;var d=new Dialog(640,null,'Edit Row');this.body=$a(d.body,'div','dialog_frm');$y(d.body,{backgroundColor:'#EEE'});d.done_btn_area=$a(d.body,'div','',{margin:'8px'});me.on_complete=function(){if(me.table_form){me.dialog.hide();}else{var callback=function(r){var dn=cur_frm.docname;if(!r.exc){me.dialog.hide();} if(me.on_save_callback) me.on_save_callback(dn);} diff --git a/js/widgets/form/form_container.js b/js/widgets/form/form_container.js index 980b952419..eacd237e37 100644 --- a/js/widgets/form/form_container.js +++ b/js/widgets/form/form_container.js @@ -5,7 +5,7 @@ _f.FrmContainer = function() { // create hidden $dh(this.wrapper); - this.body = $a(this.wrapper,'div'); + this.body = $a(this.wrapper,'div','frm_container'); // make by twin _f.frm_dialog = new _f.FrmDialog();