Merge branch 'master' of github.com:webnotes/wnframework into edge

This commit is contained in:
Anand Doshi 2013-02-20 16:07:48 +05:30
commit 320028d7b1
7 changed files with 47 additions and 33 deletions

View file

@ -46,20 +46,6 @@ class DocType:
cnt = 1
self.doc.name += '-' + str(cnt)
def validate(self):
"""
Update $image tags
"""
import re
p = re.compile('\$image\( (?P<name> [^)]*) \)', re.VERBOSE)
if self.doc.content:
self.doc.content = p.sub(self.replace_by_img, self.doc.content)
def replace_by_img(self, match):
import webnotes
name = match.group('name')
return '<img src="cgi-bin/getfile.cgi?ac=%s&name=%s">' % (webnotes.conn.get('Control Panel', None, 'account_id'), name)
# export
def on_update(self):
"""

View file

@ -53,7 +53,7 @@ _f.Frm = function(doctype, parent, in_form) {
this.docname = '';
this.doctype = doctype;
this.display = 0;
this.refresh_if_stale_for = 600;
this.refresh_if_stale_for = 120;
var me = this;
this.last_view_is_edit = {};
@ -881,16 +881,31 @@ _f.Frm.prototype.reload_doc = function() {
var me = this;
var onsave = function(r, rtxt) {
// n tweets and last comment
me.runclientscript('setup', me.doctype, me.docname);
//me.runclientscript('setup', me.doctype, me.docname);
me.refresh();
}
if(me.doc.__islocal) {
// reload only doctype
$c('webnotes.widgets.form.load.getdoctype', {'doctype':me.doctype }, onsave, null, null, 'Refreshing ' + me.doctype + '...');
wn.call({
method: "webnotes.widgets.form.load.getdoctype",
args: {
doctype: me.doctype
},
callback: function(r) {
me.refresh();
}
})
} else {
// reload doc and docytpe
$c('webnotes.widgets.form.load.getdoc', {'name':me.docname, 'doctype':me.doctype, 'getdoctype':1, 'user':user}, onsave, null, null, 'Refreshing ' + me.docname + '...');
wn.call({
method: "webnotes.widgets.form.load.getdoc",
args: {
doctype: me.doctype,
name: me.docname
},
callback: function(r) {
me.refresh();
}
});
}
}

View file

@ -40,6 +40,11 @@ $.extend(wn.model, {
if(!in_list(no_value_fields, f.fieldtype) && doc[f.fieldname]==null) {
var v = wn.model.get_default_value(f);
if(v) {
if(in_list(["Int", "Check"], f.fieldtype))
v = cint(v);
else if(in_list(["Currency", "Float"], f.fieldtype))
v = flt(v);
doc[f.fieldname] = v;
updated.push(f.fieldname);
}

View file

@ -63,7 +63,7 @@ wn.ui.Dialog = wn.ui.FieldGroup.extend({
this.appframe.$titlebar.find('.appframe-title').html(t || '');
},
set_postion: function() {
this.zindex = 1;
this.zindex = 10;
if(cur_dialog) {
this.zindex = cur_dialog.zindex + 1;
}

View file

@ -111,8 +111,17 @@ class Document:
def __str__(self):
return str(self.fields)
def __repr__(self):
return repr(self.fields)
def __unicode__(self):
return unicode(self.fields)
def __eq__(self, other):
return self.fields == other.fields
if isinstance(other, Document):
return self.fields == other.fields
else:
return False
def __getstate__(self):
return self.fields

View file

@ -72,7 +72,9 @@ def get_table_fields(doctype):
return child_tables + custom_child_tables
def has_field(doctype, fieldname):
doclist = webnotes.model.doctype.get(doctype)
return doclist.get({"parent":doctype, "doctype":"DocField", "fieldname":fieldname})
def has_field(doctype, fieldname, parent=None, parentfield=None):
return get_field(doctype, fieldname, parent=None, parentfield=None) and True or False
def get_field(doctype, fieldname, parent=None, parentfield=None):
doclist = webnotes.get_doctype(doctype)
return doclist.get_field(fieldname, parent, parentfield)

View file

@ -26,7 +26,7 @@ import webnotes.model.doc
import webnotes.utils
@webnotes.whitelist()
def getdoc():
def getdoc(doctype, name, user=None):
"""
Loads a doclist for a given document. This method is called directly from the client.
Requries "doctype", "name" as form variables.
@ -35,18 +35,15 @@ def getdoc():
import webnotes
form = webnotes.form_dict
doctype, docname = form.get('doctype'), form.get('name')
if not (doctype and docname):
if not (doctype and name):
raise Exception, 'doctype and name required!'
doclist = []
# single
doclist = load_single_doc(doctype, docname, (form.get('user') or webnotes.session['user']))
doclist = load_single_doc(doctype, name, user or webnotes.session.user)
# load doctype along with the doc
if form.get('getdoctype'):
if webnotes.form_dict.get('getdoctype'):
import webnotes.model.doctype
doclist += webnotes.model.doctype.get(doctype, processed=True)