Merge branch 'latest' of github.com:webnotes/wnframework into latest
This commit is contained in:
commit
a720f0e38f
31 changed files with 242 additions and 684 deletions
|
|
@ -141,8 +141,7 @@ div.std-footer-item {
|
|||
}
|
||||
|
||||
.layout_wrapper {
|
||||
padding: 13px;
|
||||
margin: 7px;
|
||||
padding: 15px;
|
||||
-moz-box-shadow: 1px 1px 6px #AAA;
|
||||
-webkit-box-shadow: 1px 1px 6px #AAA;
|
||||
box-shadow: 1px 1px 6px #AAA;
|
||||
|
|
|
|||
|
|
@ -145,8 +145,7 @@ div.std-footer-item {
|
|||
}
|
||||
|
||||
.layout_wrapper {
|
||||
padding: 13px;
|
||||
margin: 7px;
|
||||
padding: 15px;
|
||||
-moz-box-shadow: 1px 1px 6px #AAA;
|
||||
-webkit-box-shadow: 1px 1px 6px #AAA;
|
||||
box-shadow: 1px 1px 6px #AAA;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
var popup_cont;
|
||||
var session = {};
|
||||
var start_sid = null;
|
||||
if(!wn) var wn = {};
|
||||
|
||||
function startup() {
|
||||
|
||||
|
|
@ -15,6 +16,8 @@ function startup() {
|
|||
// Globals
|
||||
// ---------------------------------
|
||||
var setup_globals = function(r) {
|
||||
wn.boot = r;
|
||||
|
||||
profile = r.profile;
|
||||
user = r.profile.name;
|
||||
user_fullname = profile.first_name + (r.profile.last_name ? (' ' + r.profile.last_name) : '');
|
||||
|
|
@ -35,6 +38,9 @@ function startup() {
|
|||
if(r.dt_labels) {
|
||||
for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]] = key;
|
||||
}
|
||||
|
||||
// control panel
|
||||
wn.control_panel = r.control_panel;
|
||||
}
|
||||
|
||||
var setup_history = function(r) {
|
||||
|
|
@ -192,17 +198,5 @@ window.onresize = function() {
|
|||
|
||||
get_window_height = function() {
|
||||
var ht = window.innerHeight ? window.innerHeight : document.documentElement.offsetHeight ? document.documentElement.offsetHeight : document.body.offsetHeight;
|
||||
var bannerh = page_body.banner_area ? page_body.banner_area.offsetHeight : 0
|
||||
var footerh = page_body.footer ? page_body.footer.offsetHeight : 0
|
||||
ht = ht - bannerh - footerh;
|
||||
return ht;
|
||||
}
|
||||
|
||||
// setup space holder
|
||||
setup_space_holder = function() {
|
||||
// space holder div
|
||||
window.space_holder_div = $a(null,'div','space_holder');
|
||||
window.space_holder_div.innerHTML = 'Loading...'
|
||||
}
|
||||
|
||||
startup_list.push(setup_space_holder);
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ jslist=container.getElementsByTagName('script');}},show_letterhead:function(cont
|
|||
var finished=header
|
||||
+stat
|
||||
+container.innerHTML.replace(/<div/g,'\n<div').replace(/<td/g,'\n<td')
|
||||
+footer;return finished;},get_letter_head:function(){var cp=locals['Control Panel']['Control Panel'];var lh='';if(cur_frm.doc.letter_head){lh=cstr(_p.letter_heads[cur_frm.doc.letter_head]);}else if(cp.letter_head){lh=cp.letter_head;}
|
||||
+footer;return finished;},get_letter_head:function(){var cp=wn.control_panel;var lh='';if(cur_frm.doc.letter_head){lh=cstr(_p.letter_heads[cur_frm.doc.letter_head]);}else if(cp.letter_head){lh=cp.letter_head;}
|
||||
return lh;},print_style:"\
|
||||
.datalabelcell { \
|
||||
padding: 2px 0px; \
|
||||
|
|
@ -457,7 +457,7 @@ _p.build(fmt,fn);}
|
|||
_e.make=function(){var d=new Dialog(440,440,"Send Email");var email_go=function(){var emailfrom=d.widgets['From'].value;var emailto=d.widgets['To'].value;if(!emailfrom)
|
||||
emailfrom=user_email;var email_list=emailto.split(/[,|;]/);var valid=1;for(var i=0;i<email_list.length;i++){if(!validate_email(email_list[i])){msgprint('error:'+email_list[i]+' is not a valid email id');valid=0;}}
|
||||
if(emailfrom&&!validate_email(emailfrom)){msgprint('error:'+emailfrom+' is not a valid email id. To change the default please click on Profile on the top right of the screen and change it.');return;}
|
||||
if(!valid)return;var cc=emailfrom;if(!emailfrom){emailfrom=locals['Control Panel']['Control Panel'].auto_email_id;cc='';}
|
||||
if(!valid)return;var cc=emailfrom;if(!emailfrom){emailfrom=wn.control_panel.auto_email_id;cc='';}
|
||||
sendmail(emailto,emailfrom,emailfrom,d.widgets['Subject'].value,d.widgets['Message'].value,sel_val(cur_frm.print_sel),d.widgets['Send With Attachments'].checked);_e.dialog.hide();}
|
||||
d.onhide=function(){hide_autosuggest();}
|
||||
d.make_body([['Data','To','Example: abc@hotmail.com, xyz@yahoo.com'],['Select','Format'],['Data','Subject'],['Data','From','Optional'],['Check','Send With Attachments','Will send all attached documents (if any)'],['Text','Message'],['Button','Send',email_go]]);d.widgets['From'].value=(user_email?user_email:'');$td(d.rows['Format'].tab,0,1).cur_sel=d.widgets['Format'];var opts={script:'',json:true,maxresults:10};wn.require('lib/js/legacy/widgets/autosuggest.js');var as=new AutoSuggest(d.widgets['To'],opts);as.custom_select=function(txt,sel){var r='';var tl=txt.split(',');for(var i=0;i<tl.length-1;i++)r=r+tl[i]+',';r=r+(r?' ':'')+sel;if(r[r.length-1]==NEWLINE)r=substr(0,r.length-1);return r;}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Local DB
|
||||
//-----------
|
||||
|
||||
var locals = {};
|
||||
var locals = {'DocType':{}};
|
||||
var fields = {}; // fields[doctype][fieldname]
|
||||
var fields_list = {}; // fields_list[doctype]
|
||||
var LocalDB={};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function fmt_money(v){
|
|||
if(isNaN(v)) {
|
||||
return ''; // not a number
|
||||
} else {
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
var cp = wn.control_panel;
|
||||
var val = 2; // variable used to differentiate other values from Millions
|
||||
if(cp.currency_format == 'Millions') val = 3;
|
||||
v = v.toFixed(2);
|
||||
|
|
@ -275,7 +275,7 @@ var known_numbers = {
|
|||
}
|
||||
|
||||
function in_words(n) {
|
||||
var is_million = locals['Control Panel']['Control Panel'].currency_format == 'Millions' ? 1 : 0;
|
||||
var is_million = wn.control_panel.currency_format == 'Millions' ? 1 : 0;
|
||||
n=cint(n)
|
||||
if(known_numbers[n]) return known_numbers[n];
|
||||
var bestguess = n + '';
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ wn.datetime = {
|
|||
},
|
||||
|
||||
get_user_fmt: function() {
|
||||
var t = locals['Control Panel']['Control Panel'].date_format;
|
||||
var t = wn.control_panel.date_format;
|
||||
if(!t) t = 'dd-mm-yyyy';
|
||||
return t;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -452,19 +452,6 @@ function get_cookie(c) {
|
|||
return unescape(t.substring(ind+c.length+1,ind1));
|
||||
}
|
||||
|
||||
// add space holder
|
||||
add_space_holder = function(parent,cs){
|
||||
if(!cs) cs = {margin:'170px 0px'}
|
||||
$y(space_holder_div,cs);
|
||||
parent.appendChild(space_holder_div);
|
||||
}
|
||||
|
||||
// remove space holder
|
||||
remove_space_holder = function(){
|
||||
if(space_holder_div.parentNode)
|
||||
space_holder_div.parentNode.removeChild(space_holder_div);
|
||||
};
|
||||
|
||||
// URL utilities
|
||||
|
||||
wn.urllib = {
|
||||
|
|
@ -510,7 +497,7 @@ wn.urllib = {
|
|||
// by file id / name
|
||||
get_file_url: function(file_id) {
|
||||
//var url = wn.urllib.get_base_url();
|
||||
var ac_id = locals['Control Panel']['Control Panel'].account_id;
|
||||
var ac_id = wn.control_panel.account_id;
|
||||
return repl('cgi-bin/getfile.cgi?name=%(fn)s&acx=%(ac)s', {fn:file_id, ac:ac_id})
|
||||
}
|
||||
}
|
||||
|
|
@ -530,7 +517,7 @@ set_user_img = function(img, username, get_latest, img_id) {
|
|||
else if(user_img[username]=='no_img_f')
|
||||
i.src = 'lib/images/ui/no_img_f.gif'; // no image
|
||||
else {
|
||||
ac_id = locals['Control Panel']['Control Panel'].account_id;
|
||||
ac_id = wn.control_panel.account_id;
|
||||
i.src = repl('cgi-bin/getfile.cgi?ac=%(ac)s&name=%(fn)s', {fn:user_img[username], ac:ac_id});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ function $c(command, args, fn, on_timeout, no_spinner, freeze_msg) {
|
|||
if(freeze_msg)unfreeze();
|
||||
|
||||
if(!validate_session(r,rtxt)) return;
|
||||
if(r.exc) { errprint(r.exc); };
|
||||
if(r.exc) {
|
||||
errprint(r.exc);
|
||||
console.log(r.exc);
|
||||
};
|
||||
if(r.server_messages) { msgprint(r.server_messages);};
|
||||
if(r.docs) { LocalDB.sync(r.docs); }
|
||||
saveAllowed = true;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
/** Page Body
|
||||
|
||||
+ body
|
||||
+ wntoolbar
|
||||
+ banner_area
|
||||
+ body
|
||||
+ left_sidebar
|
||||
+ center
|
||||
+ right_sidebar
|
||||
+ footer
|
||||
+ dead session
|
||||
|
||||
**/
|
||||
|
|
@ -64,30 +61,11 @@ function Body() {
|
|||
}
|
||||
}
|
||||
|
||||
this.setup_header_footer = function() {
|
||||
// header
|
||||
if(cint(this.cp.header_height)) {
|
||||
var hh = this.cp.header_height ? (cint(this.cp.header_height) + 'px') : '0px';
|
||||
$y(this.header, {height:hh, borderBottom:'1px solid #CCC'});
|
||||
if(this.cp.client_name)this.banner_area.innerHTML = this.cp.client_name;
|
||||
}
|
||||
|
||||
// footer
|
||||
var fh = this.cp.footer_height ? (cint(this.cp.footer_height) + 'px') : '0px';
|
||||
$y(this.footer, {height:fh});
|
||||
if(this.cp.footer_html)this.footer.innerHTML = this.cp.footer_html;
|
||||
|
||||
}
|
||||
|
||||
this.run_startup_code = function() {
|
||||
// startup style
|
||||
if(this.cp.startup_css)
|
||||
set_style(this.cp.startup_css);
|
||||
|
||||
// startup code
|
||||
wn.require(wn.modules_path + '/startup/startup.css');
|
||||
wn.require(wn.modules_path + '/startup/startup.js');
|
||||
try{
|
||||
if(this.cp.startup_code)
|
||||
eval(this.cp.startup_code);
|
||||
if(this.cp.custom_startup_code)
|
||||
eval(this.cp.custom_startup_code);
|
||||
} catch(e) {
|
||||
|
|
@ -96,15 +74,10 @@ function Body() {
|
|||
}
|
||||
|
||||
this.setup = function() {
|
||||
this.cp = locals['Control Panel']['Control Panel'];
|
||||
this.cp = wn.control_panel;
|
||||
|
||||
this.wrapper = $a($i('body_div'),'div');
|
||||
this.banner_area = $a(this.wrapper, 'div');;
|
||||
|
||||
this.topmenu = $a(this.wrapper, 'div');
|
||||
this.breadcrumbs = $a(this.wrapper, 'div');
|
||||
this.body = $a(this.wrapper, 'div');
|
||||
this.footer = $a(this.wrapper, 'div');
|
||||
|
||||
// sidebars
|
||||
if(user_defaults.hide_sidebars) {
|
||||
|
|
@ -114,10 +87,6 @@ function Body() {
|
|||
|
||||
this.setup_page_areas();
|
||||
|
||||
|
||||
// headers & footer
|
||||
this.setup_header_footer();
|
||||
|
||||
// core areas;
|
||||
if(user=='Guest') user_defaults.hide_webnotes_toolbar = 1;
|
||||
if(!cint(user_defaults.hide_webnotes_toolbar) || user=='Administrator') {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ function makeselector() {
|
|||
btn.onclick = function() {
|
||||
if(this.disabled) return;
|
||||
|
||||
this.args.is_ajax = true;
|
||||
this.set_working();
|
||||
d.set_doctype = d.sel_type;
|
||||
var q = '';
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function Dialog(w, h, title, content) {
|
|||
this.oncancel = '';
|
||||
this.no_cancel_flag = 0; // allow to cancel
|
||||
this.display = false;
|
||||
var me = this;
|
||||
this.first_button = false;
|
||||
}
|
||||
|
||||
Dialog.prototype = new wn.widgets.Dialog()
|
||||
|
|
@ -110,9 +110,13 @@ Dialog.prototype.make_row = function(d) {
|
|||
}
|
||||
else if(d[0]=='Button') {
|
||||
c2.style.height = '32px';
|
||||
c2.style.textAlign = 'right';
|
||||
var b = $btn(c2, d[1], function(btn) { if(btn._onclick) btn._onclick(me) }, null, null, 1);
|
||||
var b = $btn(c2, d[1], function(btn) {
|
||||
if(btn._onclick) btn._onclick(me) }, null, null, 1);
|
||||
b.dialog = me;
|
||||
if(!this.first_button) {
|
||||
$(b).addClass('primary');
|
||||
this.first_button = true;
|
||||
}
|
||||
if(d[2]) {
|
||||
b._onclick = d[2];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ _e.make = function() {
|
|||
var cc= emailfrom;
|
||||
|
||||
if(!emailfrom) {
|
||||
emailfrom = locals['Control Panel']['Control Panel'].auto_email_id;
|
||||
emailfrom = wn.control_panel.auto_email_id;
|
||||
cc = '';
|
||||
}
|
||||
sendmail(emailto, emailfrom, emailfrom, d.widgets['Subject'].value, d.widgets['Message'].value, sel_val(cur_frm.print_sel), d.widgets['Send With Attachments'].checked);
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ function DateField() { } DateField.prototype = new Field();
|
|||
DateField.prototype.make_input = function() {
|
||||
|
||||
var me = this;
|
||||
this.user_fmt = locals['Control Panel']['Control Panel'].date_format;
|
||||
this.user_fmt = wn.control_panel.date_format;
|
||||
if(!this.user_fmt)this.user_fmt = 'dd-mm-yy';
|
||||
|
||||
this.input = $a(this.input_area, 'input');
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ $.extend(_p, {
|
|||
|
||||
// fetches letter head from current doc or control panel
|
||||
get_letter_head: function() {
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
var cp = wn.control_panel;
|
||||
var lh = '';
|
||||
if(cur_frm.doc.letter_head) {
|
||||
lh = cstr(_p.letter_heads[cur_frm.doc.letter_head]);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ var frms={};var cur_frm=null;var pscript={};var validated=true;var validation_me
|
|||
*/
|
||||
|
||||
var startup_list=[];wn.utils.full_name=function(fn,ln){return fn+(ln?' ':'')+(ln?ln:'')}
|
||||
function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var cp=locals['Control Panel']['Control Panel'];var val=2;if(cp.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
|
||||
function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var cp=wn.control_panel;var val=2;if(cp.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
|
||||
var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return'';}
|
||||
var minus='';if(v<0){minus='-';}
|
||||
i=Math.abs(i);var n=new String(i);var a=[];if(n.length>3)
|
||||
|
|
@ -63,7 +63,7 @@ return"{"+l.join(',')+'}';}
|
|||
function ie_refresh(e){$dh(e);$ds(e);}
|
||||
function DocLink(p,doctype,name,onload){var a=$a(p,'span','link_type');a.innerHTML=a.dn=name;a.dt=doctype;a.onclick=function(){loaddoc(this.dt,this.dn,onload)};return a;}
|
||||
var doc_link=DocLink;var known_numbers={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve',13:'thirteen',14:'fourteen',15:'fifteen',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen',20:'twenty',30:'thirty',40:'forty',50:'fifty',60:'sixty',70:'seventy',80:'eighty',90:'ninety'}
|
||||
function in_words(n){var is_million=locals['Control Panel']['Control Panel'].currency_format=='Millions'?1:0;n=cint(n)
|
||||
function in_words(n){var is_million=wn.control_panel.currency_format=='Millions'?1:0;n=cint(n)
|
||||
if(known_numbers[n])return known_numbers[n];var bestguess=n+'';var remainder=0
|
||||
if(n<=20)
|
||||
alert('Error while converting to words');else if(n<100){return in_words(Math.floor(n/10)*10)+'-'+in_words(n%10);}else if(n<1000){bestguess=in_words(Math.floor(n/100))+' '+'hundred';remainder=n%100;}else if(!is_million){if(n<100000){bestguess=in_words(Math.floor(n/1000))+' '+'thousand';remainder=n%1000;}else if(n<10000000){bestguess=in_words(Math.floor(n/100000))+' '+'lakh';remainder=n%100000;}else{bestguess=in_words(Math.floor(n/10000000))+' '+'crore'
|
||||
|
|
@ -93,7 +93,7 @@ if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],
|
|||
new_dt=new Date(dt.getFullYear(),dt.getMonth()+months,dt.getDate())
|
||||
if(new_dt.getDate()!=dt.getDate()){return dateutil.month_end(new Date(dt.getFullYear(),dt.getMonth()+months,1))}
|
||||
return dateutil.obj_to_str(new_dt);},month_start:function(){var d=new Date();return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-01';},month_end:function(d){if(!d)var d=new Date();var m=d.getMonth()+1;var y=d.getFullYear();last_date=month_last[m];if(m==2&&(y%4)==0&&((y%100)!=0||(y%400)==0))
|
||||
last_date=29;return y+'-'+int_to_str(m,2)+'-'+last_date;},get_user_fmt:function(){var t=locals['Control Panel']['Control Panel'].date_format;if(!t)t='dd-mm-yyyy';return t;},str_to_user:function(val,no_time_str){var user_fmt=dateutil.get_user_fmt();var time_str='';if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');if(tmp[1])
|
||||
last_date=29;return y+'-'+int_to_str(m,2)+'-'+last_date;},get_user_fmt:function(){var t=wn.control_panel.date_format;if(!t)t='dd-mm-yyyy';return t;},str_to_user:function(val,no_time_str){var user_fmt=dateutil.get_user_fmt();var time_str='';if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');if(tmp[1])
|
||||
time_str=' '+tmp[1];var d=tmp[0];}else{var d=val;}
|
||||
if(no_time_str)time_str='';d=d.split('-');if(d.length==3){if(user_fmt=='dd-mm-yyyy')
|
||||
val=d[2]+'-'+d[1]+'-'+d[0]+time_str;else if(user_fmt=='dd/mm/yyyy')
|
||||
|
|
@ -217,19 +217,16 @@ function get_scroll_top(){var st=0;if(document.documentElement&&document.documen
|
|||
st=document.documentElement.scrollTop;else if(document.body&&document.body.scrollTop)
|
||||
st=document.body.scrollTop;return st;}
|
||||
function get_cookie(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==-1||c=="")return"";var ind1=t.indexOf(';',ind);if(ind1==-1)ind1=t.length;return unescape(t.substring(ind+c.length+1,ind1));}
|
||||
add_space_holder=function(parent,cs){if(!cs)cs={margin:'170px 0px'}
|
||||
$y(space_holder_div,cs);parent.appendChild(space_holder_div);}
|
||||
remove_space_holder=function(){if(space_holder_div.parentNode)
|
||||
space_holder_div.parentNode.removeChild(space_holder_div);};wn.urllib={get_arg:function(name){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null)
|
||||
wn.urllib={get_arg:function(name){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null)
|
||||
return"";else
|
||||
return decodeURIComponent(results[1]);},get_dict:function(){var d={}
|
||||
var t=window.location.href.split('?')[1];if(!t)return d;if(t.indexOf('#')!=-1)t=t.split('#')[0];if(!t)return d;t=t.split('&');for(var i=0;i<t.length;i++){var a=t[i].split('=');d[decodeURIComponent(a[0])]=decodeURIComponent(a[1]);}
|
||||
return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('index.html')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
|
||||
return url},get_file_url:function(file_id){var ac_id=locals['Control Panel']['Control Panel'].account_id;return repl('cgi-bin/getfile.cgi?name=%(fn)s&acx=%(ac)s',{fn:file_id,ac:ac_id})}}
|
||||
return url},get_file_url:function(file_id){var ac_id=wn.control_panel.account_id;return repl('cgi-bin/getfile.cgi?name=%(fn)s&acx=%(ac)s',{fn:file_id,ac:ac_id})}}
|
||||
get_url_arg=wn.urllib.get_arg;get_url_dict=wn.urllib.get_dict;var user_img={}
|
||||
var user_img_queue={};var user_img_loading=[];set_user_img=function(img,username,get_latest,img_id){function set_it(i){if(user_img[username]=='no_img_m')
|
||||
i.src='lib/images/ui/no_img_m.gif';else if(user_img[username]=='no_img_f')
|
||||
i.src='lib/images/ui/no_img_f.gif';else{ac_id=locals['Control Panel']['Control Panel'].account_id;i.src=repl('cgi-bin/getfile.cgi?ac=%(ac)s&name=%(fn)s',{fn:user_img[username],ac:ac_id});}}
|
||||
i.src='lib/images/ui/no_img_f.gif';else{ac_id=wn.control_panel.account_id;i.src=repl('cgi-bin/getfile.cgi?ac=%(ac)s&name=%(fn)s',{fn:user_img[username],ac:ac_id});}}
|
||||
if(img_id){user_img[username]=img_id;set_it(img);return;}
|
||||
if(user_img[username]&&!get_latest){set_it(img);}else{if(in_list(user_img_loading,username)){if(!user_img_queue[username])
|
||||
user_img_queue[username]=[];user_img_queue[username].push(img);return;}
|
||||
|
|
@ -246,7 +243,7 @@ var pending_req=0;function newHttpReq(){if(!isIE)
|
|||
var r=new XMLHttpRequest();else if(window.ActiveXObject)
|
||||
var r=new ActiveXObject("Microsoft.XMLHTTP");return r;}
|
||||
function $c(command,args,fn,on_timeout,no_spinner,freeze_msg){var req=newHttpReq();ret_fn=function(){if(checkResponse(req,on_timeout,no_spinner,freeze_msg)){if(!no_spinner)hide_loading();var rtxt=req.responseText;try{var r=JSON.parse(rtxt);}catch(e){alert('Handler Exception:'+rtxt);return;}
|
||||
if(freeze_msg)unfreeze();if(!validate_session(r,rtxt))return;if(r.exc){errprint(r.exc);};if(r.server_messages){msgprint(r.server_messages);};if(r.docs){LocalDB.sync(r.docs);}
|
||||
if(freeze_msg)unfreeze();if(!validate_session(r,rtxt))return;if(r.exc){errprint(r.exc);console.log(r.exc);};if(r.server_messages){msgprint(r.server_messages);};if(r.docs){LocalDB.sync(r.docs);}
|
||||
saveAllowed=true;if(fn)fn(r,rtxt);}}
|
||||
req.onreadystatechange=ret_fn;req.open("POST",outUrl,true);req.setRequestHeader("ENCTYPE","multipart/form-data");req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");args['cmd']=command;req.send(makeArgString(args));if(!no_spinner)set_loading();if(freeze_msg)freeze(freeze_msg,1);}
|
||||
function validate_session(r,rt){if(r.message=='Logged In'){start_sid=get_cookie('sid');return true;}
|
||||
|
|
@ -373,7 +370,7 @@ cur_dialog.hide();}});
|
|||
* lib/js/legacy/widgets/dialog.js
|
||||
*/
|
||||
|
||||
var cur_dialog;var top_index=91;function Dialog(w,h,title,content){wn.require('lib/js/legacy/widgets/form/fields.js');this.make({width:w,title:title});if(content)this.make_body(content);this.onshow='';this.oncancel='';this.no_cancel_flag=0;this.display=false;var me=this;}
|
||||
var cur_dialog;var top_index=91;function Dialog(w,h,title,content){wn.require('lib/js/legacy/widgets/form/fields.js');this.make({width:w,title:title});if(content)this.make_body(content);this.onshow='';this.oncancel='';this.no_cancel_flag=0;this.display=false;this.first_button=false;}
|
||||
Dialog.prototype=new wn.widgets.Dialog()
|
||||
Dialog.prototype.make_body=function(content){this.rows={};this.widgets={};for(var i in content)this.make_row(content[i]);}
|
||||
Dialog.prototype.clear_inputs=function(d){for(var wid in this.widgets){var w=this.widgets[wid];var tn=w.tagName?w.tagName.toLowerCase():'';if(tn=='input'||tn=='textarea'){w.value='';}else if(tn=='select'){sel_val(w.options[0].value);}else if(w.txt){w.txt.value='';}else if(w.input){w.input.value='';}}}
|
||||
|
|
@ -388,7 +385,8 @@ else if(d[0]=='Password'){c1.innerHTML=d[1];c2.style.overflow='auto';this.widget
|
|||
else if(d[0]=='Select'){c1.innerHTML=d[1];this.widgets[d[1]]=$a(c2,'select','',{width:'160px'})
|
||||
if(d[2])$a(c2,'div','field_description').innerHTML=d[2];if(d[3])add_sel_options(this.widgets[d[1]],d[3],d[3][0]);}
|
||||
else if(d[0]=='Text'){c1.innerHTML=d[1];c2.style.overflow='auto';this.widgets[d[1]]=$a(c2,'textarea');if(d[2])$a(c2,'div','field_description').innerHTML=d[2];}
|
||||
else if(d[0]=='Button'){c2.style.height='32px';c2.style.textAlign='right';var b=$btn(c2,d[1],function(btn){if(btn._onclick)btn._onclick(me)},null,null,1);b.dialog=me;if(d[2]){b._onclick=d[2];}
|
||||
else if(d[0]=='Button'){c2.style.height='32px';var b=$btn(c2,d[1],function(btn){if(btn._onclick)btn._onclick(me)},null,null,1);b.dialog=me;if(!this.first_button){$(b).addClass('primary');this.first_button=true;}
|
||||
if(d[2]){b._onclick=d[2];}
|
||||
this.widgets[d[1]]=b;}}
|
||||
/*
|
||||
* lib/js/legacy/widgets/listing.js
|
||||
|
|
@ -727,7 +725,7 @@ if(d.input)d.input.set_get_query();var get_sf_list=function(dt){var l=[];var lf=
|
|||
$ds(d.rows['Search By']);if(search_fields[d.sel_type]){empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type),'ID');}else{empty_select(field_sel);add_sel_options(field_sel,['ID'],'ID');$c('webnotes.widgets.search.getsearchfields',{'doctype':d.sel_type},function(r,rt){search_fields[d.sel_type]=r.searchfields;empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type));field_sel.selectedIndex=0;});}}
|
||||
d.onhide=function(){if(d.input&&d.input.txt)
|
||||
d.input.txt.onchange()}
|
||||
btn.onclick=function(){if(this.disabled)return;this.set_working();d.set_doctype=d.sel_type;var q='';args={};if(d.input&&d.input.get_query){var doc={};args.is_simple=1;if(cur_frm)doc=locals[cur_frm.doctype][cur_frm.docname];var q=d.input.get_query(doc,d.input.doctype,d.input.docname);if(!q){return'';}}
|
||||
btn.onclick=function(){if(this.disabled)return;this.args.is_ajax=true;this.set_working();d.set_doctype=d.sel_type;var q='';args={};if(d.input&&d.input.get_query){var doc={};args.is_simple=1;if(cur_frm)doc=locals[cur_frm.doctype][cur_frm.docname];var q=d.input.get_query(doc,d.input.doctype,d.input.docname);if(!q){return'';}}
|
||||
var get_sf_fieldname=function(v){var lf=search_fields[d.sel_type];if(!lf)
|
||||
return'name'
|
||||
for(var i=0;i<lf.length;i++)if(lf[i][1]==v)return lf[i][0];}
|
||||
|
|
@ -881,7 +879,7 @@ this.make();}
|
|||
* lib/js/legacy/model/local_data.js
|
||||
*/
|
||||
|
||||
var locals={};var fields={};var fields_list={};var LocalDB={};var READ=0;var WRITE=1;var CREATE=2;var SUBMIT=3;var CANCEL=4;var AMEND=5;LocalDB.getchildren=function(child_dt,parent,parentfield,parenttype){var l=[];for(var key in locals[child_dt]){var d=locals[child_dt][key];if((d.parent==parent)&&(d.parentfield==parentfield)){if(parenttype){if(d.parenttype==parenttype)l.push(d);}else{l.push(d);}}}
|
||||
var locals={'DocType':{}};var fields={};var fields_list={};var LocalDB={};var READ=0;var WRITE=1;var CREATE=2;var SUBMIT=3;var CANCEL=4;var AMEND=5;LocalDB.getchildren=function(child_dt,parent,parentfield,parenttype){var l=[];for(var key in locals[child_dt]){var d=locals[child_dt][key];if((d.parent==parent)&&(d.parentfield==parentfield)){if(parenttype){if(d.parenttype==parenttype)l.push(d);}else{l.push(d);}}}
|
||||
l.sort(function(a,b){return(cint(a.idx)-cint(b.idx))});return l;}
|
||||
LocalDB.add=function(dt,dn){if(!locals[dt])locals[dt]={};if(locals[dt][dn])delete locals[dt][dn];locals[dt][dn]={'name':dn,'doctype':dt,'docstatus':0};return locals[dt][dn];}
|
||||
LocalDB.delete_doc=function(dt,dn){var doc=get_local(dt,dn);for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||doc.__oldparent==dn)){delete locals[ndt][ndn];}}}}
|
||||
|
|
@ -977,14 +975,10 @@ this.setup_page_areas=function(){var n=this.no_of_columns();this.body_table=make
|
|||
c++;}
|
||||
this.center.header=$a(this.center,'div');this.center.body=$a(this.center,'div');this.center.loading=$a(this.center,'div','',{margin:'200px 0px',fontSize:'14px',color:'#999',textAlign:'center'});this.center.loading.innerHTML='Loading...'}
|
||||
this.setup_sidebar_menu=function(){if(this.left_sidebar&&this.cp.show_sidebar_menu){sidebar_menu=new SidebarMenu();sidebar_menu.make_menu('');}}
|
||||
this.setup_header_footer=function(){if(cint(this.cp.header_height)){var hh=this.cp.header_height?(cint(this.cp.header_height)+'px'):'0px';$y(this.header,{height:hh,borderBottom:'1px solid #CCC'});if(this.cp.client_name)this.banner_area.innerHTML=this.cp.client_name;}
|
||||
var fh=this.cp.footer_height?(cint(this.cp.footer_height)+'px'):'0px';$y(this.footer,{height:fh});if(this.cp.footer_html)this.footer.innerHTML=this.cp.footer_html;}
|
||||
this.run_startup_code=function(){if(this.cp.startup_css)
|
||||
set_style(this.cp.startup_css);try{if(this.cp.startup_code)
|
||||
eval(this.cp.startup_code);if(this.cp.custom_startup_code)
|
||||
this.run_startup_code=function(){wn.require(wn.modules_path+'/startup/startup.css');wn.require(wn.modules_path+'/startup/startup.js');try{if(this.cp.custom_startup_code)
|
||||
eval(this.cp.custom_startup_code);}catch(e){errprint(e);}}
|
||||
this.setup=function(){this.cp=locals['Control Panel']['Control Panel'];this.wrapper=$a($i('body_div'),'div');this.banner_area=$a(this.wrapper,'div');;this.topmenu=$a(this.wrapper,'div');this.breadcrumbs=$a(this.wrapper,'div');this.body=$a(this.wrapper,'div');this.footer=$a(this.wrapper,'div');if(user_defaults.hide_sidebars){this.cp.left_sidebar_width=null;this.cp.right_sidebar_width=null;}
|
||||
this.setup_page_areas();this.setup_header_footer();if(user=='Guest')user_defaults.hide_webnotes_toolbar=1;if(!cint(user_defaults.hide_webnotes_toolbar)||user=='Administrator'){wn.provide('wn.ui.toolbar');wn.require('lib/js/wn/ui/toolbar.min.js');this.wntoolbar=new wn.ui.toolbar.Toolbar();}
|
||||
this.setup=function(){this.cp=wn.control_panel;this.wrapper=$a($i('body_div'),'div');this.body=$a(this.wrapper,'div');if(user_defaults.hide_sidebars){this.cp.left_sidebar_width=null;this.cp.right_sidebar_width=null;}
|
||||
this.setup_page_areas();if(user=='Guest')user_defaults.hide_webnotes_toolbar=1;if(!cint(user_defaults.hide_webnotes_toolbar)||user=='Administrator'){wn.provide('wn.ui.toolbar');wn.require('lib/js/wn/ui/toolbar.min.js');this.wntoolbar=new wn.ui.toolbar.Toolbar();}
|
||||
if(this.cp.page_width)$y(this.wrapper,{width:cint(this.cp.page_width)+'px'});}
|
||||
this.pages={};this.cur_page=null;this.add_page=function(label,onshow,onhide){var c=$a(this.center.body,'div');if(onshow)
|
||||
c.onshow=onshow;if(onhide)
|
||||
|
|
@ -1001,8 +995,9 @@ this.setup();}
|
|||
* lib/js/legacy/app.js
|
||||
*/
|
||||
|
||||
var popup_cont;var session={};var start_sid=null;function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){profile=r.profile;user=r.profile.name;user_fullname=profile.first_name+(r.profile.last_name?(' '+r.profile.last_name):'');user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;profile.start_items=r.start_items;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={}
|
||||
_tags.color_map=r.tag_color_map;if(r.dt_labels){for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]]=key;}}
|
||||
var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=profile.first_name+(r.profile.last_name?(' '+r.profile.last_name):'');user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;profile.start_items=r.start_items;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={}
|
||||
_tags.color_map=r.tag_color_map;if(r.dt_labels){for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]]=key;}
|
||||
wn.control_panel=r.control_panel;}
|
||||
var setup_history=function(r){rename_observers.push(nav_obj);}
|
||||
var setup_events=function(){addEvent('keyup',function(ev,target){for(var i in keypress_observers){if(keypress_observers[i])
|
||||
keypress_observers[i].notify_keypress(ev,ev.keyCode);}});addEvent('click',function(ev,target){for(var i=0;i<click_observers.length;i++){if(click_observers[i])
|
||||
|
|
@ -1034,8 +1029,4 @@ window.onscroll=function(){for(var i=0;i<scroll_list.length;i++){scroll_list[i](
|
|||
var resize_observers=[]
|
||||
function set_resize_observer(fn){if(resize_observers.indexOf(fn)==-1)resize_observers.push(fn);}
|
||||
window.onresize=function(){return;var ht=get_window_height();for(var i=0;i<resize_observers.length;i++){resize_observers[i](ht);}}
|
||||
get_window_height=function(){var ht=window.innerHeight?window.innerHeight:document.documentElement.offsetHeight?document.documentElement.offsetHeight:document.body.offsetHeight;var bannerh=page_body.banner_area?page_body.banner_area.offsetHeight:0
|
||||
var footerh=page_body.footer?page_body.footer.offsetHeight:0
|
||||
ht=ht-bannerh-footerh;return ht;}
|
||||
setup_space_holder=function(){window.space_holder_div=$a(null,'div','space_holder');window.space_holder_div.innerHTML='Loading...'}
|
||||
startup_list.push(setup_space_holder);
|
||||
get_window_height=function(){var ht=window.innerHeight?window.innerHeight:document.documentElement.offsetHeight?document.documentElement.offsetHeight:document.body.offsetHeight;return ht;}
|
||||
|
|
@ -3,9 +3,10 @@ wn.ui.Button = function(args) {
|
|||
$.extend(this, {
|
||||
make: function() {
|
||||
me.btn = wn.dom.add(args.parent, 'button', 'btn small ' + (args.css_class || ''));
|
||||
me.btn.args = args;
|
||||
|
||||
// ajax loading
|
||||
me.loading_img = wn.dom.add(args.parent,'img','',{margin:'0px 4px -2px 4px', display:'none'});
|
||||
me.loading_img = wn.dom.add(me.btn.args.parent,'img','',{margin:'0px 4px -2px 4px', display:'none'});
|
||||
me.loading_img.src= 'lib/images/ui/button-load.gif';
|
||||
if(args.is_ajax) wn.dom.css(me.btn,{marginRight:'24px'});
|
||||
|
||||
|
|
@ -24,22 +25,24 @@ wn.ui.Button = function(args) {
|
|||
me.btn.done_working = me.done_working;
|
||||
|
||||
// style
|
||||
if(args.style)
|
||||
if(me.btn.args.style)
|
||||
wn.dom.css(me.btn, args.style);
|
||||
},
|
||||
|
||||
set_working: function() {
|
||||
me.btn.disabled = 'disabled';
|
||||
if(me.btn.args.is_ajax) {
|
||||
$(me.btn).css('margin-right', '0px');
|
||||
}
|
||||
wn.dom.show(me.loading_img, 'inline');
|
||||
if(args.is_ajax)
|
||||
wn.dom.css(me.btn,{marginRight:'0px'});
|
||||
},
|
||||
|
||||
done_working: function() {
|
||||
me.btn.disabled = false;
|
||||
if(me.btn.args.is_ajax) {
|
||||
$(me.btn).css('margin-right', '24px');
|
||||
}
|
||||
wn.dom.hide(me.loading_img);
|
||||
if(args.is_ajax)
|
||||
wn.dom.css(me.btn,{marginRight:'24px'});
|
||||
}
|
||||
});
|
||||
this.make();
|
||||
|
|
|
|||
4
js/wn/ui/toolbar.min.js
vendored
4
js/wn/ui/toolbar.min.js
vendored
|
|
@ -87,10 +87,10 @@ wn.ui.toolbar.Report=wn.ui.toolbar.SelectorDialog.extend({init:function(){this._
|
|||
wn.ui.toolbar.RecentDocs=Class.extend({init:function(){$('.topbar .nav:first').append('<li class="dropdown">\
|
||||
<a class="dropdown-toggle" href="#" onclick="return false;">Recent</a>\
|
||||
<ul class="dropdown-menu" id="toolbar-recent"></ul>\
|
||||
</li>');this.setup();this.bind_events();},bind_events:function(){rename_observers.push(this);},rename_notify:function(dt,old,name){this.remove(dt,old);this.add(dt,name,1);},add:function(dt,dn,on_top){this.remove(dt,dn);var html=repl('<li data-docref="%(dt)s/%(dn)s">\
|
||||
</li>');this.setup();this.bind_events();},bind_events:function(){rename_observers.push(this);},rename_notify:function(dt,old,name){this.remove(dt,old);this.add(dt,name,1);},add:function(dt,dn,on_top){if(this.istable(dt))return;this.remove(dt,dn);var html=repl('<li data-docref="%(dt)s/%(dn)s">\
|
||||
<a href="#Form/%(dt)s/%(dn)s">\
|
||||
<span class="help">%(dt)s</span>: %(dn)s\
|
||||
</a></li>',{dt:dt,dn:dn});if(on_top){$('#toolbar-recent').prepend(html);}else{$('#toolbar-recent').append(html);}},remove:function(dt,dn){$(repl('#toolbar-recent li[data-docref="%(dt)s/%(dn)s"]',{dt:dt,dn:dn})).remove();},setup:function(){try{var rlist=JSON.parse(profile.recent);}
|
||||
</a></li>',{dt:dt,dn:dn});if(on_top){$('#toolbar-recent').prepend(html);}else{$('#toolbar-recent').append(html);}},istable:function(dt){return locals.DocType[dt]&&locals.DocType[dt].istable||false;},remove:function(dt,dn){$(repl('#toolbar-recent li[data-docref="%(dt)s/%(dn)s"]',{dt:dt,dn:dn})).remove();},setup:function(){try{var rlist=JSON.parse(profile.recent);}
|
||||
catch(e){return;}
|
||||
var m=rlist.length;if(m>15)m=15;for(var i=0;i<m;i++){var rd=rlist[i]
|
||||
if(rd[1]){var dt=rd[0];var dn=rd[1];this.add(dt,dn,0);}}}});
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ wn.ui.toolbar.RecentDocs = Class.extend({
|
|||
this.add(dt, name, 1);
|
||||
},
|
||||
add: function(dt, dn, on_top) {
|
||||
if(this.istable(dt)) return;
|
||||
|
||||
this.remove(dt, dn);
|
||||
var html = repl('<li data-docref="%(dt)s/%(dn)s">\
|
||||
<a href="#Form/%(dt)s/%(dn)s">\
|
||||
|
|
@ -28,6 +30,9 @@ wn.ui.toolbar.RecentDocs = Class.extend({
|
|||
$('#toolbar-recent').append(html);
|
||||
}
|
||||
},
|
||||
istable: function(dt) {
|
||||
return locals.DocType[dt] && locals.DocType[dt].istable || false;
|
||||
},
|
||||
remove: function(dt, dn) {
|
||||
$(repl('#toolbar-recent li[data-docref="%(dt)s/%(dn)s"]', {dt:dt, dn:dn})).remove();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,5 +76,5 @@ class Project:
|
|||
for fname in wt[2]:
|
||||
if fname=='build.json':
|
||||
self.bundle.make(os.path.join(wt[0], fname))
|
||||
|
||||
|
||||
self.render_templates()
|
||||
|
|
@ -3,24 +3,24 @@
|
|||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-05-12 11:19:11',
|
||||
'creation': '2012-01-24 12:47:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-02-12 17:04:27',
|
||||
'modified': '2012-01-24 12:50:01',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1307624201',
|
||||
'_last_update': '1327389019',
|
||||
'allow_copy': 0,
|
||||
'allow_email': 0,
|
||||
'allow_print': 0,
|
||||
'colour': 'White:FFF',
|
||||
'default_print_format': 'Standard',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'idx': 0,
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'istable': 0,
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
'server_code_error': ' ',
|
||||
'show_in_menu': 1,
|
||||
'smallicon': 'controller.png',
|
||||
'version': 21
|
||||
'version': 25
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
|
|
@ -50,7 +50,6 @@
|
|||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'execute': 0,
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Control Panel',
|
||||
'parentfield': 'permissions',
|
||||
|
|
@ -77,7 +76,6 @@
|
|||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'General',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -87,7 +85,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'date_format',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'label': 'Date Format',
|
||||
'options': 'yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy',
|
||||
'permlevel': 0
|
||||
|
|
@ -98,7 +95,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'currency_format',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 3,
|
||||
'label': 'Currency Format',
|
||||
'options': 'Millions\nLacs',
|
||||
'permlevel': 0
|
||||
|
|
@ -109,7 +105,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'password_expiry_days',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 4,
|
||||
'label': 'Password Expires in (days)',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -121,7 +116,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'session_expiry',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Session Expires in (time)',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -131,17 +125,22 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'sync_with_gateway',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 6,
|
||||
'label': 'Sync with Gateway',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'title',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 7,
|
||||
'label': 'Title',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -151,7 +150,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'account_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'label': 'Account Id',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -161,7 +159,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'company_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 9,
|
||||
'label': 'Company Name',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -171,7 +168,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'industry',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'label': 'Industry',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -181,7 +177,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'time_zone',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 11,
|
||||
'label': 'Time Zone',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -191,7 +186,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'country',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Country',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -201,7 +195,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'total_sms_sent',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 13,
|
||||
'label': 'Total SMS Sent',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
|
@ -210,189 +203,6 @@
|
|||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 14,
|
||||
'label': 'Home Pages',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'default_home_pages',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 15,
|
||||
'label': 'Default Home Pages',
|
||||
'options': 'Default Home Page',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'home_page',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 16,
|
||||
'label': 'Home Page',
|
||||
'options': 'Page',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 17,
|
||||
'label': 'Startup',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'startup_code',
|
||||
'fieldtype': 'Code',
|
||||
'idx': 18,
|
||||
'label': 'Startup Code (JS)',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'startup_css',
|
||||
'fieldtype': 'Code',
|
||||
'idx': 19,
|
||||
'label': 'Startup CSS',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 20,
|
||||
'label': 'Display',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 21,
|
||||
'label': 'Display Options',
|
||||
'permlevel': 0,
|
||||
'width': '100%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'Default page width is auto',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'page_width',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 22,
|
||||
'label': 'Page WIdth',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'hide_webnotes_toolbar',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 23,
|
||||
'label': 'Hide WebNotes Toolbar',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'background_color',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 24,
|
||||
'label': 'Background Color',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 25,
|
||||
'label': 'Header / Footer',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'Default header height is 40px',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'header_height',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 26,
|
||||
'label': 'Header Height',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'client_name',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 27,
|
||||
'label': 'Header HTML',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'footer_height',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 28,
|
||||
'label': 'Footer Height',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'footer_html',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 29,
|
||||
'label': 'Footer HTML',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'letter_head',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 30,
|
||||
'label': 'Letter Head',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'client_logo',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 31,
|
||||
'label': 'Client Logo',
|
||||
'options': 'File',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 32,
|
||||
'label': 'Mail Server',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -403,7 +213,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'support_email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 33,
|
||||
'label': 'Support Email Id',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -413,7 +222,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'letter_head_image',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 34,
|
||||
'label': 'Letter Head Image',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -424,7 +232,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'auto_email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 35,
|
||||
'label': 'Auto Email Id',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -436,17 +243,22 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'outgoing_mail_server',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 36,
|
||||
'label': 'Outgoing Mail Server',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mail_port',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 37,
|
||||
'label': 'Mail Port',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -456,7 +268,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'use_ssl',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 38,
|
||||
'label': 'Use SSL',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -466,7 +277,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'mail_login',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 39,
|
||||
'label': 'Login Id',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -476,7 +286,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'mail_password',
|
||||
'fieldtype': 'Password',
|
||||
'idx': 40,
|
||||
'label': 'Mail Password',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -486,7 +295,6 @@
|
|||
'doctype': 'DocField',
|
||||
'fieldname': 'mail_footer',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 41,
|
||||
'label': 'Mail Footer',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -495,7 +303,6 @@
|
|||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 42,
|
||||
'label': 'Defaults',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
|
@ -506,7 +313,6 @@
|
|||
'fieldname': 'system_defaults',
|
||||
'fieldtype': 'Table',
|
||||
'hidden': 0,
|
||||
'idx': 43,
|
||||
'label': 'System Defaults',
|
||||
'options': 'DefaultValue',
|
||||
'permlevel': 0,
|
||||
|
|
@ -518,30 +324,16 @@
|
|||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 44,
|
||||
'label': 'Sidebars',
|
||||
'label': 'Banner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'To hide the left sidebar, leave this blank or 0',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'left_sidebar_width',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 45,
|
||||
'label': 'Left Sidebar Width',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'To hide the right sidebar, leave this blank or 0',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'right_sidebar_width',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 46,
|
||||
'label': 'Right Sidebar Width',
|
||||
'fieldname': 'client_name',
|
||||
'fieldtype': 'Text',
|
||||
'label': 'Banner HTML',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
|
|
@ -549,39 +341,44 @@
|
|||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 47,
|
||||
'label': 'Test Script',
|
||||
'label': 'Startup',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 48,
|
||||
'label': 'Execute Local',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'icon': 'accept.png',
|
||||
'idx': 49,
|
||||
'label': 'Execute (Careful!)',
|
||||
'options': 'execute_test',
|
||||
'permlevel': 0,
|
||||
'width': '150px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'test_code',
|
||||
'fieldname': 'custom_startup_code',
|
||||
'fieldtype': 'Code',
|
||||
'idx': 50,
|
||||
'label': 'Test Code',
|
||||
'label': 'Custom Startup Code',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'label': 'Home Pages',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'home_page',
|
||||
'fieldtype': 'Link',
|
||||
'label': 'Home Page',
|
||||
'options': 'Page',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'default_home_pages',
|
||||
'fieldtype': 'Table',
|
||||
'label': 'Default Home Pages',
|
||||
'options': 'Default Home Page',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
#body_div {
|
||||
width: 960px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.login-banner {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ pscript['onload_Login Page'] = function(){
|
|||
|
||||
pscript['onshow_Login Page'] = function() {
|
||||
// set banner
|
||||
var bannerhtml = locals['Control Panel']['Control Panel'].client_name;
|
||||
var bannerhtml = wn.control_panel.client_name;
|
||||
if(bannerhtml) $('.login-banner').html(bannerhtml);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,10 @@ class CookieManager:
|
|||
# -----------
|
||||
|
||||
def set_cookies(self):
|
||||
webnotes.cookies['account_id'] = webnotes.conn.cur_db_name
|
||||
if webnotes.form_dict.get('cmd')=='logout':
|
||||
webnotes.cookies['account_id'] = ''
|
||||
else:
|
||||
webnotes.cookies['account_id'] = webnotes.conn.cur_db_name
|
||||
|
||||
if webnotes.session.get('sid'):
|
||||
webnotes.cookies['sid'] = webnotes.session['sid']
|
||||
|
|
|
|||
76
py/webnotes/boot.py
Normal file
76
py/webnotes/boot.py
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
"""
|
||||
bootstrap client session
|
||||
"""
|
||||
|
||||
|
||||
def get_bootinfo():
|
||||
"""build and return boot info"""
|
||||
import webnotes
|
||||
bootinfo = {}
|
||||
doclist = []
|
||||
|
||||
webnotes.conn.begin()
|
||||
|
||||
# profile
|
||||
get_profile(bootinfo)
|
||||
|
||||
# control panel
|
||||
import webnotes.model.doc
|
||||
cp = webnotes.model.doc.getsingle('Control Panel')
|
||||
|
||||
# system info
|
||||
bootinfo['control_panel'] = cp
|
||||
bootinfo['account_name'] = cp.get('account_id')
|
||||
bootinfo['sysdefaults'] = webnotes.utils.get_defaults()
|
||||
|
||||
if webnotes.session['user'] != 'Guest':
|
||||
import webnotes.widgets.menus
|
||||
bootinfo['start_items'] = webnotes.widgets.menus.get_menu_items()
|
||||
bootinfo['dt_labels'] = get_dt_labels()
|
||||
|
||||
# home page
|
||||
get_home_page(bootinfo, doclist)
|
||||
|
||||
# ipinfo
|
||||
if webnotes.session['data'].get('ipinfo'):
|
||||
bootinfo['ipinfo'] = webnotes.session['data']['ipinfo']
|
||||
|
||||
# add docs
|
||||
bootinfo['docs'] = doclist
|
||||
|
||||
# plugins
|
||||
import startup.event_handlers
|
||||
if getattr(startup.event_handlers, 'boot_session'):
|
||||
startup.event_handlers.boot_session(bootinfo)
|
||||
|
||||
webnotes.conn.commit()
|
||||
|
||||
return bootinfo
|
||||
|
||||
def get_profile(bootinfo):
|
||||
"""get profile info"""
|
||||
import webnotes
|
||||
bootinfo['profile'] = webnotes.user.load_profile()
|
||||
webnotes.session['data']['profile'] = bootinfo['profile']
|
||||
|
||||
def get_home_page(bootinfo, doclist):
|
||||
"""load home page"""
|
||||
import webnotes
|
||||
home_page = webnotes.user.get_home_page()
|
||||
if home_page:
|
||||
import webnotes.widgets.page
|
||||
doclist += webnotes.widgets.page.get(home_page)
|
||||
bootinfo['home_page'] = home_page or ''
|
||||
|
||||
def get_dt_labels():
|
||||
import webnotes
|
||||
d = {}
|
||||
try:
|
||||
res = webnotes.conn.sql("select name, dt_label from `tabDocType Label`")
|
||||
except:
|
||||
return {}
|
||||
|
||||
for r in res:
|
||||
d[r[0]] = r[1]
|
||||
|
||||
return d
|
||||
|
|
@ -93,21 +93,6 @@ def delete_doc(doctype=None, name=None, doclist = None, force=0):
|
|||
|
||||
return 'okay'
|
||||
|
||||
#=================================================================================
|
||||
# new feature added 9-Jun-10 to allow doctypes to have labels
|
||||
def get_dt_labels():
|
||||
d = {}
|
||||
try:
|
||||
res = webnotes.conn.sql("select name, dt_label from `tabDocType Label`")
|
||||
except:
|
||||
return {}
|
||||
|
||||
for r in res:
|
||||
d[r[0]] = r[1]
|
||||
|
||||
return d
|
||||
#=================================================================================
|
||||
|
||||
def get_search_criteria(dt):
|
||||
import webnotes.model.doc
|
||||
# load search criteria for reports (all)
|
||||
|
|
|
|||
|
|
@ -130,8 +130,7 @@ class Document:
|
|||
|
||||
def _loadsingle(self):
|
||||
self.name = self.doctype
|
||||
dataset = webnotes.conn.sql("select field, value from tabSingles where doctype='%s'" % self.doctype)
|
||||
for d in dataset: self.fields[d[0]] = d[1]
|
||||
self.fields.update(getsingle(self.doctype))
|
||||
|
||||
# Setter
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -671,9 +670,6 @@ def get(dt, dn='', with_children = 1, from_get_obj = 0, prefix = 'tab'):
|
|||
webnotes.response['exc_type'] = 'PermissionError'
|
||||
raise webnotes.ValidationError, '[WNF] No read permission for %s %s' % (dt, dn)
|
||||
|
||||
# import report_builder code
|
||||
get_report_builder_code(doc)
|
||||
|
||||
if not with_children:
|
||||
# done
|
||||
return [doc,]
|
||||
|
|
@ -686,4 +682,14 @@ def get(dt, dn='', with_children = 1, from_get_obj = 0, prefix = 'tab'):
|
|||
for t in tablefields:
|
||||
doclist += getchildren(doc.name, t[0], t[1], dt, prefix=prefix)
|
||||
|
||||
# import report_builder code
|
||||
if not from_get_obj:
|
||||
get_report_builder_code(doc)
|
||||
|
||||
return doclist
|
||||
|
||||
def getsingle(doctype):
|
||||
"""get single doc as dict"""
|
||||
dataset = webnotes.conn.sql("select field, value from tabSingles where doctype=%s", doctype)
|
||||
return dict(dataset)
|
||||
|
||||
|
|
@ -60,7 +60,8 @@ def execute_patch(patchmodule, method=None, methodargs=None):
|
|||
|
||||
def add_to_patch_log(tb):
|
||||
"""add error log to patches/patch.log"""
|
||||
with open('patches/patch.log','a') as patchlog:
|
||||
import webnotes.defs, os
|
||||
with open(os.path.join(webnotes.defs.modules_path,'patches','patch.log'),'a') as patchlog:
|
||||
patchlog.write('\n\n' + tb)
|
||||
|
||||
def update_patch_log(patchmodule):
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
# session_cache.py
|
||||
"""
|
||||
Boot session from cache or build
|
||||
|
||||
# clear cache
|
||||
# ==================================================
|
||||
Session bootstraps info needed by common client side activities including
|
||||
permission, homepage, control panel variables, system defaults etc
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
def clear():
|
||||
"""clear all cache"""
|
||||
clear_cache()
|
||||
|
||||
import webnotes
|
||||
webnotes.response['message'] = "Cache Cleared"
|
||||
|
||||
def clear_cache(user=''):
|
||||
import webnotes
|
||||
"""clear cache"""
|
||||
try:
|
||||
if user:
|
||||
webnotes.conn.sql("delete from __SessionCache where user=%s", user)
|
||||
|
|
@ -22,14 +24,10 @@ def clear_cache(user=''):
|
|||
else:
|
||||
raise e
|
||||
|
||||
# load cache
|
||||
# ==================================================
|
||||
|
||||
def get():
|
||||
import webnotes
|
||||
"""get session boot info"""
|
||||
import webnotes.defs
|
||||
|
||||
|
||||
# get country
|
||||
country = webnotes.session['data'].get('ipinfo', {}).get('countryName', 'Unknown Country')
|
||||
|
||||
|
|
@ -40,20 +38,14 @@ def get():
|
|||
return cache
|
||||
|
||||
# if not create it
|
||||
sd = build()
|
||||
dump(sd, country)
|
||||
|
||||
# update profile from cache
|
||||
webnotes.session['data']['profile'] = sd['profile']
|
||||
import webnotes.boot
|
||||
bootinfo = webnotes.boot.get_bootinfo()
|
||||
add_to_cache(bootinfo, country)
|
||||
|
||||
return sd
|
||||
|
||||
# load cache
|
||||
# ==================================================
|
||||
return bootinfo
|
||||
|
||||
def load(country):
|
||||
import webnotes
|
||||
|
||||
"""load from cache"""
|
||||
try:
|
||||
sd = webnotes.conn.sql("select cache from __SessionCache where user='%s' %s" % (webnotes.session['user'], (country and (" and country='%s'" % country) or '')))
|
||||
if sd:
|
||||
|
|
@ -65,21 +57,9 @@ def load(country):
|
|||
make_cache_table()
|
||||
else:
|
||||
raise e
|
||||
|
||||
# make the cache table
|
||||
# ==================================================
|
||||
|
||||
def make_cache_table():
|
||||
import webnotes
|
||||
webnotes.conn.commit()
|
||||
webnotes.conn.sql("create table `__SessionCache` (user VARCHAR(120), country VARCHAR(120), cache LONGTEXT)")
|
||||
webnotes.conn.begin()
|
||||
|
||||
# dump session to cache
|
||||
# ==================================================
|
||||
|
||||
def dump(sd, country):
|
||||
import webnotes
|
||||
|
||||
def add_to_cache(sd, country):
|
||||
"""add to cache"""
|
||||
import webnotes.model.utils
|
||||
|
||||
if sd.get('docs'):
|
||||
|
|
@ -91,80 +71,7 @@ def dump(sd, country):
|
|||
# make new
|
||||
webnotes.conn.sql("insert into `__SessionCache` (user, country, cache) VALUES (%s, %s, %s)", (webnotes.session['user'], country, str(sd)))
|
||||
|
||||
# ==================================================
|
||||
|
||||
def get_letter_heads():
|
||||
import webnotes
|
||||
try:
|
||||
lh = {}
|
||||
ret = webnotes.conn.sql("select name, content from `tabLetter Head` where ifnull(disabled,0)=0")
|
||||
for r in ret:
|
||||
lh[r[0]] = r[1]
|
||||
return lh
|
||||
except Exception, e:
|
||||
if e.args[0]==1146:
|
||||
return {}
|
||||
else:
|
||||
raise Exception, e
|
||||
|
||||
# ==================================================
|
||||
# load startup.js and startup.css from the modules/startup folder
|
||||
|
||||
def load_startup(cp):
|
||||
from webnotes.modules import ModuleFile
|
||||
|
||||
try: from webnotes.defs import modules_path
|
||||
except ImportError: return
|
||||
|
||||
import os
|
||||
|
||||
cp.startup_code = ModuleFile(os.path.join(modules_path, 'startup', 'startup.js')).load_content()
|
||||
cp.startup_css = ModuleFile(os.path.join(modules_path, 'startup', 'startup.css')).load_content()
|
||||
|
||||
# build it
|
||||
# ==================================================
|
||||
|
||||
def build():
|
||||
sd = {}
|
||||
|
||||
import webnotes
|
||||
import webnotes.model
|
||||
import webnotes.model.doc
|
||||
import webnotes.model.doctype
|
||||
import webnotes.widgets.page
|
||||
import webnotes.widgets.menus
|
||||
import webnotes.profile
|
||||
import webnotes.defs
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
webnotes.conn.begin()
|
||||
sd['profile'] = webnotes.user.load_profile()
|
||||
|
||||
doclist = []
|
||||
doclist += webnotes.model.doc.get('Control Panel')
|
||||
cp = doclist[0]
|
||||
load_startup(cp)
|
||||
|
||||
doclist += webnotes.model.doctype.get('Event')
|
||||
doclist += webnotes.model.doctype.get('Search Criteria')
|
||||
home_page = webnotes.user.get_home_page()
|
||||
|
||||
if home_page:
|
||||
doclist += webnotes.widgets.page.get(home_page)
|
||||
|
||||
sd['account_name'] = cp.account_id or ''
|
||||
sd['sysdefaults'] = webnotes.utils.get_defaults()
|
||||
sd['n_online'] = int(sql("SELECT COUNT(DISTINCT user) FROM tabSessions")[0][0] or 0)
|
||||
sd['docs'] = doclist
|
||||
sd['letter_heads'] = get_letter_heads()
|
||||
sd['home_page'] = home_page or ''
|
||||
sd['start_items'] = webnotes.widgets.menus.get_menu_items()
|
||||
if webnotes.session['data'].get('ipinfo'):
|
||||
sd['ipinfo'] = webnotes.session['data']['ipinfo']
|
||||
|
||||
webnotes.session['data']['profile'] = sd['profile']
|
||||
sd['dt_labels'] = webnotes.model.get_dt_labels()
|
||||
def make_cache_table():
|
||||
webnotes.conn.commit()
|
||||
|
||||
return sd
|
||||
webnotes.conn.sql("create table `__SessionCache` (user VARCHAR(120), country VARCHAR(120), cache LONGTEXT)")
|
||||
webnotes.conn.begin()
|
||||
|
|
|
|||
|
|
@ -1,171 +0,0 @@
|
|||
"""
|
||||
startup info for the app
|
||||
|
||||
client needs info that is static across all users
|
||||
and user specific info like roles and defaults
|
||||
|
||||
so calling will be:
|
||||
index.cgi?cmd=webnotes.startup.common_info
|
||||
index.cgi?cmd=webnotes.startup.user_info&user=x@y.com
|
||||
|
||||
to clear startup,
|
||||
you must clear all files in the vcs starting with index.cgi?cmd=webnotes.startup
|
||||
"""
|
||||
|
||||
import webnotes
|
||||
|
||||
|
||||
def get_letter_heads():
|
||||
"""
|
||||
get letter head
|
||||
"""
|
||||
import webnotes
|
||||
try:
|
||||
lh = {}
|
||||
ret = webnotes.conn.sql("select name, content from `tabLetter Head` where ifnull(disabled,0)=0")
|
||||
for r in ret:
|
||||
lh[r[0]] = r[1]
|
||||
return lh
|
||||
except Exception, e:
|
||||
if e.args[0]==1146:
|
||||
return {}
|
||||
else:
|
||||
raise Exception, e
|
||||
|
||||
|
||||
|
||||
|
||||
def get_content_user():
|
||||
"""
|
||||
get user specific content
|
||||
"""
|
||||
import webnotes
|
||||
import webnotes.utils
|
||||
import webnotes.widgets.page
|
||||
import webnotes.widgets.menus
|
||||
|
||||
user = webnotes.form_dict['user']
|
||||
doclist, ret = [], {}
|
||||
|
||||
webnotes.conn.begin()
|
||||
ret['profile'] = webnotes.user.load_profile()
|
||||
home_page = webnotes.user.get_home_page()
|
||||
if home_page:
|
||||
doclist += webnotes.widgets.page.get(home_page)
|
||||
|
||||
ret['sysdefaults'] = webnotes.utils.get_defaults()
|
||||
ret['home_page'] = home_page or ''
|
||||
|
||||
# role-wise menus
|
||||
ret['start_items'] = webnotes.widgets.menus.get_menu_items()
|
||||
|
||||
# bundle
|
||||
webnotes.session['data']['profile'] = ret['profile']
|
||||
if webnotes.session['data'].get('ipinfo'):
|
||||
ret['ipinfo'] = webnotes.session['data']['ipinfo']
|
||||
|
||||
webnotes.conn.commit()
|
||||
|
||||
webnotes.response['docs'] = doclist
|
||||
|
||||
return ret
|
||||
|
||||
def get_content_common():
|
||||
"""
|
||||
build common startup info
|
||||
"""
|
||||
|
||||
import webnotes
|
||||
import webnotes.model.doc
|
||||
import webnotes.model.doctype
|
||||
import webnotes.model
|
||||
|
||||
doclist, ret = [], {}
|
||||
doclist += webnotes.model.doc.get('Control Panel')
|
||||
doclist += webnotes.model.doctype.get('Event')
|
||||
doclist += webnotes.model.doctype.get('Search Criteria')
|
||||
|
||||
cp = doclist[0]
|
||||
ret['account_name'] = cp.account_id or ''
|
||||
ret['letter_heads'] = get_letter_heads()
|
||||
ret['dt_labels'] = webnotes.model.get_dt_labels()
|
||||
|
||||
webnotes.response['docs'] = doclist
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def common_info():
|
||||
"""
|
||||
get common startup info (from version or live)
|
||||
"""
|
||||
get_info('index.cgi?cmd=webnotes.startup.common_info', 'common')
|
||||
|
||||
def user_info():
|
||||
"""
|
||||
get user info
|
||||
"""
|
||||
user = webnotes.form_dict['user']
|
||||
get_info('index.cgi?cmd=webnotes.startup.user_info&user='+user, 'user')
|
||||
|
||||
def get_info(fname, key):
|
||||
"""
|
||||
get info from version or re-build
|
||||
"""
|
||||
from build.version import VersionControl
|
||||
|
||||
vc = VersionControl()
|
||||
|
||||
# from versions (same static)
|
||||
|
||||
if vc.exists(fname):
|
||||
content = vc.get_file(fname)['content']
|
||||
else:
|
||||
content = globals().get('get_content_'+key)()
|
||||
import json
|
||||
content = json.dumps(content)
|
||||
|
||||
# add in vcs
|
||||
vc.add(fname=fname, content=content)
|
||||
vc.commit()
|
||||
|
||||
vc.close()
|
||||
|
||||
webnotes.response['content'] = content
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def clear_info(info_type=None):
|
||||
"""
|
||||
clear startup info and force a new version
|
||||
|
||||
parameter: info_type = 'user' or 'common' or 'all'
|
||||
"""
|
||||
if not info_type:
|
||||
info_type = webnotes.form_dict.get('info_type')
|
||||
|
||||
from build.version import VersionControl
|
||||
vc = VersionControl()
|
||||
|
||||
flist = []
|
||||
|
||||
if info_type=='common':
|
||||
flist = ['index.cgi?cmd=webnotes.startup.common_info']
|
||||
elif info_type=='user':
|
||||
flist = [f[0] for f in vc.repo.sql("""select fname from files where fname like ?""",\
|
||||
('index.cgi?cmd=webnotes.startup.user_info%',))]
|
||||
elif info_type=='all':
|
||||
flist = [f[0] for f in vc.repo.sql("""select fname from files where fname like ?""",\
|
||||
('index.cgi?cmd=webnotes.startup%',))]
|
||||
else:
|
||||
webnotes.msgprint("info_type not found: %s" % info_type)
|
||||
|
||||
for f in flist:
|
||||
print 'clearing %s' % f
|
||||
vc.remove(f)
|
||||
|
||||
vc.commit()
|
||||
vc.close()
|
||||
4
wnf.py
4
wnf.py
|
|
@ -45,6 +45,10 @@ def run():
|
|||
if cmd=='build':
|
||||
from build.project import Project
|
||||
Project().build()
|
||||
|
||||
elif cmd=='clear':
|
||||
from build.project import Project
|
||||
Project().render_templates()
|
||||
|
||||
# replace code
|
||||
elif cmd=='replace':
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue