Merge branch 'master' into cms2
Conflicts: py/webnotes/__init__.py
This commit is contained in:
commit
d2d310060d
12 changed files with 48 additions and 41 deletions
3
js/core.min.js
vendored
3
js/core.min.js
vendored
|
|
@ -228,7 +228,8 @@ df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.field
|
|||
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
|
||||
if(cond=='like'){val=val+'%';}
|
||||
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
|
||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
|
||||
if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
|
||||
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
|
||||
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ _f.Frm.prototype.add_custom_button = function(label, fn, icon) {
|
|||
this.frm_head.appframe.add_button(label, fn, icon);
|
||||
}
|
||||
_f.Frm.prototype.clear_custom_buttons = function() {
|
||||
//
|
||||
this.frm_head.refresh_toolbar()
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ wn.widgets.form.sidebar.Attachment = function(parent, filedet, frm) {
|
|||
|
||||
// download
|
||||
var display_name = this.fileid;
|
||||
if(this.fileid.substr(0,8)=='FileData')
|
||||
if(this.fileid && this.fileid.substr(0,8)=='FileData')
|
||||
display_name = this.filename;
|
||||
this.ln = $a(this.wrapper, 'a', 'link_type small', {}, display_name);
|
||||
this.ln.href = 'files/'+this.fileid;
|
||||
|
|
|
|||
|
|
@ -283,12 +283,29 @@ wn.ui.FieldSelect = Class.extend({
|
|||
me.table_fields = [];
|
||||
var std_filters = [
|
||||
{fieldname:'name', fieldtype:'Data', label:'ID', parent:me.doctype},
|
||||
{fieldname:'modified', fieldtype:'Date', label:'Last Modified', parent:me.doctype},
|
||||
{fieldname:'owner', fieldtype:'Data', label:'Created By', parent:me.doctype},
|
||||
{fieldname:'creation', fieldtype:'Date', label:'Created On', parent:me.doctype},
|
||||
{fieldname:'_user_tags', fieldtype:'Data', label:'Tags', parent:me.doctype}
|
||||
{fieldname:'modified', fieldtype:'Date', label:'Last Modified',
|
||||
parent:me.doctype},
|
||||
{fieldname:'owner', fieldtype:'Data', label:'Created By',
|
||||
parent:me.doctype},
|
||||
{fieldname:'creation', fieldtype:'Date', label:'Created On',
|
||||
parent:me.doctype},
|
||||
{fieldname:'_user_tags', fieldtype:'Data', label:'Tags',
|
||||
parent:me.doctype},
|
||||
{fieldname:'docstatus', fieldtype:'Int', label:'Doc Status',
|
||||
parent:me.doctype},
|
||||
];
|
||||
|
||||
// add parenttype column
|
||||
var doctype_obj = locals['DocType'][me.doctype];
|
||||
if(doctype_obj && cint(doctype_obj.istable)) {
|
||||
std_filters = std_filters.concat([{
|
||||
fieldname: 'parent',
|
||||
fieldtype: 'Data',
|
||||
label: 'Parent',
|
||||
parent: me.doctype
|
||||
}]);
|
||||
}
|
||||
|
||||
// blank
|
||||
if(this.with_blank) {
|
||||
this.$select.append($('<option>', {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ wn.views.ReportView = wn.ui.Listing.extend({
|
|||
show_filters: true,
|
||||
new_doctype: this.doctype,
|
||||
allow_delete: true,
|
||||
});
|
||||
});
|
||||
this.make_column_picker();
|
||||
this.make_sorter();
|
||||
this.make_export();
|
||||
|
|
|
|||
|
|
@ -47,19 +47,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||
<a href="#!List/Custom%20Script">Custom Script</a> \
|
||||
and <a href="#!List/Property%20Setter">Property Setter</a>')
|
||||
}
|
||||
|
||||
|
||||
// show button for import
|
||||
cur_frm.add_custom_button('Import from File', cur_frm.cscript.do_import);
|
||||
}
|
||||
|
||||
cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||
doc.server_code_compiled = null;
|
||||
}
|
||||
|
||||
cur_frm.cscript.do_import = function(doc, cdt, cdn) {
|
||||
callback = function(r,rt) {
|
||||
cur_frm.refresh_doc();
|
||||
}
|
||||
$c_obj([doc], 'import_doctype', '', callback)
|
||||
}
|
||||
}
|
||||
|
|
@ -102,11 +102,11 @@ class DocType:
|
|||
self.scrub_field_names()
|
||||
self.validate_fields()
|
||||
self.set_version()
|
||||
self.make_amendable()
|
||||
self.make_file_list()
|
||||
|
||||
|
||||
def on_update(self):
|
||||
self.make_amendable()
|
||||
self.make_file_list()
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
# make schma changes
|
||||
from webnotes.model.db_schema import updatedb
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def get_template():
|
|||
|
||||
doctype_dl = webnotes.model.doctype.get(doctype)
|
||||
tablecolumns = [f[0] for f in webnotes.conn.sql('desc `tab%s`' % doctype)]
|
||||
|
||||
|
||||
def getinforow(docfield):
|
||||
"""make info comment"""
|
||||
if docfield.fieldtype == 'Select':
|
||||
|
|
@ -68,7 +68,7 @@ def get_template():
|
|||
def append_row(t, mandatory):
|
||||
docfield = getdocfield(t)
|
||||
if docfield and ((mandatory and docfield.reqd) or (not mandatory and not docfield.reqd)) \
|
||||
and (t not in ('parenttype', 'trash_reason')):
|
||||
and (t not in ('parenttype', 'trash_reason', 'file_list')):
|
||||
fieldrow.append(t)
|
||||
mandatoryrow.append(docfield.reqd and 'Yes' or 'No')
|
||||
typerow.append(docfield.fieldtype)
|
||||
|
|
|
|||
|
|
@ -97,14 +97,6 @@ def msgprint(msg, small=0, raise_exception=0, as_table=False):
|
|||
if raise_exception:
|
||||
raise ValidationError, msg
|
||||
|
||||
def is_apache_user():
|
||||
import os
|
||||
if os.environ.get('USER') == 'apache':
|
||||
return True
|
||||
else:
|
||||
return (not os.environ.get('USER'))
|
||||
# os.environ does not have user, so allows a security vulnerability,fixed now.
|
||||
|
||||
def get_index_path():
|
||||
import os
|
||||
return os.sep.join(os.path.dirname(os.path.abspath(__file__)).split(os.sep)[:-2])
|
||||
|
|
@ -153,9 +145,6 @@ def connect(db_name=None, password=None):
|
|||
"""
|
||||
Connect to this db (or db), if called from command prompt
|
||||
"""
|
||||
#if is_apache_user():
|
||||
# raise Exception, 'Not for web users!'
|
||||
|
||||
import webnotes.db
|
||||
global conn
|
||||
conn = webnotes.db.Database(user=db_name, password=password)
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class _DocType:
|
|||
for doc_type in doc_type_list:
|
||||
docfields = self.get_sorted_docfields(doclist, doc_type)
|
||||
docfields = self.sort_docfields(doc_type, docfields, prev_field_dict)
|
||||
if docfields: self.change_idx(doclist, docfields)
|
||||
if docfields: self.change_idx(doclist, docfields, doc_type)
|
||||
|
||||
def get_previous_field_properties(self, property_dict):
|
||||
"""
|
||||
|
|
@ -252,9 +252,9 @@ class _DocType:
|
|||
|
||||
return docfields
|
||||
|
||||
def change_idx(self, doclist, docfields):
|
||||
def change_idx(self, doclist, docfields, doc_type):
|
||||
for d in doclist:
|
||||
if d.fieldname and d.fieldname in docfields:
|
||||
if d.fieldname and d.fieldname in docfields and d.parent == doc_type:
|
||||
d.idx = docfields.index(d.fieldname) + 1
|
||||
|
||||
def add_code(self, doc):
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ def get_module_path(module):
|
|||
|
||||
def reload_doc(module, dt=None, dn=None):
|
||||
"""reload single / list of records"""
|
||||
|
||||
if type(module) is list:
|
||||
for m in module:
|
||||
reload_single_doc(m[0], m[1], m[2])
|
||||
|
|
@ -60,6 +61,9 @@ def reload_doc(module, dt=None, dn=None):
|
|||
|
||||
def reload_single_doc(module, dt, dn, force=False):
|
||||
"""Sync a file from txt if modifed, return false if not updated"""
|
||||
if dt.lower() == 'doctype':
|
||||
return
|
||||
|
||||
import os
|
||||
dt, dn = scrub_dt_dn(dt, dn)
|
||||
|
||||
|
|
|
|||
|
|
@ -66,14 +66,21 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', txt=None, \
|
|||
# if not html, then lets put some whitespace
|
||||
if (not '<br>' in msg) and (not '<p>' in msg):
|
||||
msg = msg.replace('\n','<br>')
|
||||
|
||||
|
||||
footer = get_footer()
|
||||
|
||||
# encode using utf-8
|
||||
footer = footer.encode('utf-8', 'ignore')
|
||||
|
||||
msg = msg + (footer or '')
|
||||
if txt:
|
||||
email.set_text(txt)
|
||||
else:
|
||||
try:
|
||||
email.set_text(html2text(msg))
|
||||
msg_unicode = msg
|
||||
if isinstance(msg, str):
|
||||
msg_unicode = unicode(msg, 'utf-8', 'ignore')
|
||||
email.set_text(html2text(msg_unicode))
|
||||
except HTMLParser.HTMLParseError:
|
||||
pass
|
||||
email.set_html(msg)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue