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

This commit is contained in:
Nabin Hait 2012-06-22 12:16:51 +05:30
commit e73bedb256
5 changed files with 31 additions and 17 deletions

View file

@ -43,7 +43,7 @@ wn.provide('_f');
_f.frms = {};
_f.Frm = function(doctype, parent) {
_f.Frm = function(doctype, parent, in_form) {
this.docname = '';
this.doctype = doctype;
this.display = 0;
@ -61,6 +61,9 @@ _f.Frm = function(doctype, parent) {
this.setup_meta(doctype);
// show in form instead of in dialog, when called using url (router.js)
this.in_form = in_form ? true : false;
// notify on rename
var me = this;
$(document).bind('rename', function(event, dt, old_name, new_name) {
@ -142,8 +145,8 @@ _f.Frm.prototype.onhide = function() { if(_f.cur_grid_cell) _f.cur_grid_cell.gri
_f.Frm.prototype.setup_std_layout = function() {
this.page_layout = new wn.PageLayout({
parent: this.wrapper,
main_width: this.meta.in_dialog ? '100%' : '75%',
sidebar_width: this.meta.in_dialog ? '0%' : '25%'
main_width: (this.meta.in_dialog && !this.in_form) ? '100%' : '75%',
sidebar_width: (this.meta.in_dialog && !this.in_form) ? '0%' : '25%'
})
// only tray
@ -153,7 +156,7 @@ _f.Frm.prototype.setup_std_layout = function() {
this.layout = new Layout(this.page_layout.body, '100%');
// sidebar
if(this.meta.in_dialog) {
if(this.meta.in_dialog && !this.in_form) {
// hide sidebar
$(this.page_layout.wrapper).removeClass('layout-wrapper-background');
$(this.page_layout.main).removeClass('layout-main-section');
@ -168,7 +171,7 @@ _f.Frm.prototype.setup_std_layout = function() {
// header - no headers for tables and guests
if(!(this.meta.istable || user=='Guest' || this.meta.in_dialog))
if(!(this.meta.istable || user=='Guest' || (this.meta.in_dialog && !this.in_form)))
this.frm_head = new _f.FrmHeader(this.page_layout.head, this);
// bg colour
@ -246,7 +249,7 @@ _f.Frm.prototype.email_doc = function() {
_f.Frm.prototype.rename_notify = function(dt, old, name) {
// from form
if(this.meta.in_dialog)
if(this.meta.in_dialog && !this.in_form)
return;
if(this.docname == old)
@ -276,7 +279,7 @@ _f.Frm.prototype.rename_notify = function(dt, old, name) {
// ======================================================================================
_f.Frm.prototype.setup_meta = function() {
_f.Frm.prototype.setup_meta = function(doctype) {
this.meta = get_local('DocType',this.doctype);
this.perm = get_perm(this.doctype); // for create
if(this.meta.istable) { this.meta.in_dialog = 1 }
@ -471,7 +474,7 @@ _f.Frm.prototype.get_doc_perms = function() {
_f.Frm.prototype.refresh_header = function() {
// set title
// main title
if(!this.meta.in_dialog) {
if(!this.meta.in_dialog || this.in_form) {
set_title(this.meta.issingle ? this.doctype : this.docname);
}
@ -514,7 +517,7 @@ _f.Frm.prototype.check_doc_perm = function() {
_f.Frm.prototype.refresh = function(docname) {
// record switch
if(docname) {
if(this.docname != docname && !this.meta.in_dialog && !this.meta.istable) scroll(0, 0);
if(this.docname != docname && (!this.meta.in_dialog || this.in_form) && !this.meta.istable) scroll(0, 0);
this.docname = docname;
}
if(!this.meta.istable) {
@ -613,7 +616,7 @@ _f.Frm.prototype.refresh = function(docname) {
_f.Frm.prototype.refresh_footer = function() {
var f = this.page_layout.footer;
if(f.save_area) {
if(get_url_arg('embed') || (this.editable && !this.meta.in_dialog && this.doc.docstatus==0 && !this.meta.istable && this.get_doc_perms()[WRITE])) {
if(get_url_arg('embed') || (this.editable && (!this.meta.in_dialog || this.in_form) && this.doc.docstatus==0 && !this.meta.istable && this.get_doc_perms()[WRITE])) {
f.show_save();
} else {
f.hide_save();

View file

@ -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;

View file

@ -19,7 +19,7 @@ wn.views.formview = {
}
if(!wn.views.formview[dt]) {
wn.views.formview[dt] = wn.container.add_page('Form - ' + dt);
wn.views.formview[dt].frm = new _f.Frm(dt, wn.views.formview[dt]);
wn.views.formview[dt].frm = new _f.Frm(dt, wn.views.formview[dt], true);
}
wn.container.change_to('Form - ' + dt);
wn.views.formview[dt].frm.refresh(dn);

View file

@ -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)
@ -153,7 +153,11 @@ def upload():
# doctype
doctype = rows[0][0].split(':')[1].strip()
doctype_dl = webnotes.model.doctype.get(doctype, form=0)
if doctype in ['Customer', 'Supplier'] and len(rows[8:]) > 100:
webnotes.msgprint("Please upload only upto 100 %ss at a time" % doctype)
raise Exception
parenttype, parentfield = None, None
if len(rows[1]) > 0 and ':' in rows[1][0]:
parenttype = rows[1][0].split(':')[1].strip()

View file

@ -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)