Browse Source

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

version-14
Rushabh Mehta 12 years ago
parent
commit
93ca093069
5 changed files with 32 additions and 29 deletions
  1. +2
    -2
      public/js/legacy/widgets/form/print_format.js
  2. +2
    -13
      public/js/wn/print/print_table.js
  3. +6
    -0
      webnotes/utils/__init__.py
  4. +21
    -13
      webnotes/utils/email_lib/smtp.py
  5. +1
    -1
      webnotes/utils/file_manager.py

+ 2
- 2
public/js/legacy/widgets/form/print_format.js View File

@@ -25,7 +25,7 @@ _p.def_print_style_body = "html, body, div, span, td { \
font-family: Arial, Helvetica; \
font-size: 9pt; \
}\
pre { margin:0; padding:0;}"
pre { margin:0; padding:0;}";

_p.def_print_style_other = "\n.simpletable, .noborder { \
border-collapse: collapse;\
@@ -38,7 +38,7 @@ _p.def_print_style_other = "\n.simpletable, .noborder { \
}\
.noborder td {\
vertical-align: top;\
}"
}";

_p.go = function(html) {
var d = document.createElement('div')


+ 2
- 13
public/js/wn/print/print_table.js View File

@@ -114,12 +114,6 @@ wn.print.Table = Class.extend({
.css({"width": me.widths[ci]})
.appendTo(headrow)
if(ci==0) {
td.css({"min-width": "30px"});
} else {
td.css({"min-width": "5%"});
}
if(df && in_list(['Float', 'Currency'], df.fieldtype)) {
td.css({"text-align": "right"});
}
@@ -150,12 +144,6 @@ wn.print.Table = Class.extend({
.css(me.cell_style)
.css({width: me.widths[ci]})
.appendTo(tr);
if(ci==0) {
td.css({"min-width": "30px"});
} else {
td.css({"min-width": "5%"});
}
});
}
});
@@ -178,7 +166,8 @@ wn.print.Table = Class.extend({
});

this.widths = $.map(this.widths, function(w) {
return (flt(w) / sum * 100).toFixed(0) + "%";
w = (flt(w) / sum * 100).toFixed(0);
return (w < 5 ? 5 : w) + "%";
});
}
},


+ 6
- 0
webnotes/utils/__init__.py View File

@@ -79,6 +79,12 @@ def get_email_id(user):
fullname = get_fullname(user)
return formataddr((fullname, user))
def extract_email_id(email):
"""fetch only the email part of the email id"""
import re
sender_email = re.findall("<([^>]*)>", email)
return sender_email and sender_email[0] or ""
def validate_email_add(email_str):
"""Validates the email string"""
from email.utils import parseaddr


+ 21
- 13
webnotes/utils/email_lib/smtp.py View File

@@ -185,21 +185,29 @@ class EMail:
def validate(self):
"""validate the email ids"""
from webnotes.utils import validate_email_add, extract_email_id
def _validate(email):
"""validate an email field"""
if email:
if not validate_email_add(email):
# try extracting the email part and set as sender
new_email = extract_email_id(email)
if not (new_email and validate_email_add(new_email)):
webnotes.msgprint("%s is not a valid email id" % email,
raise_exception = 1)
email = new_email
return email
if not self.sender:
self.sender = webnotes.conn.get_value('Email Settings', None, 'auto_email_id') \
or getattr(conf, 'auto_email_id', 'ERPNext Notification <notification@erpnext.com>')

from webnotes.utils import validate_email_add
# validate ids
if self.sender and (not validate_email_add(self.sender)):
webnotes.msgprint("%s is not a valid email id" % self.sender, raise_exception = 1)

if self.reply_to and (not validate_email_add(self.reply_to)):
webnotes.msgprint("%s is not a valid email id" % self.reply_to, raise_exception = 1)

# TODO: remove erpnext id
self.sender = webnotes.conn.get_value('Email Settings', None,
'auto_email_id') or getattr(conf, 'auto_email_id')
self.sender = _validate(self.sender)
self.reply_to = _validate(self.reply_to)
for e in self.recipients + (self.cc or []):
if e.strip() and not validate_email_add(e):
webnotes.msgprint("%s is not a valid email id" % e, raise_exception = 1)
_validate(e.strip())
def make(self):
"""build into msg_root"""


+ 1
- 1
webnotes/utils/file_manager.py View File

@@ -127,7 +127,7 @@ def save_file(fname, content, module=None):
f.file_name = fname
f.save(1)
# rename new file
os.rename(new_fname, os.path.join(get_files_path(), f.name))
os.rename(new_fname, os.path.join(get_files_path(), f.name))
return f.name

def check_max_file_size(content):


Loading…
Cancel
Save