From 32671fd67b76cbb7f6187f1661bbee35163bce45 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 6 Dec 2011 18:52:42 +0530 Subject: [PATCH 1/2] Changes in email lib to send email from defs specifications --- py/core/doctype/print_format/print_format.txt | 8 ++++---- py/webnotes/defs_template.py | 3 +++ py/webnotes/utils/email_lib/__init__.py | 4 ++-- py/webnotes/utils/email_lib/send.py | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/py/core/doctype/print_format/print_format.txt b/py/core/doctype/print_format/print_format.txt index 054e272381..b8ee2ce453 100644 --- a/py/core/doctype/print_format/print_format.txt +++ b/py/core/doctype/print_format/print_format.txt @@ -5,14 +5,14 @@ { 'creation': '2009-05-12 16:43:58', 'docstatus': 0, - 'modified': '2011-11-23 13:39:59', + 'modified': '2011-12-05 11:45:45', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { - '_last_update': '1321362800', + '_last_update': '1322035799', 'allow_attach': 0, 'allow_copy': 0, 'allow_email': 0, @@ -40,7 +40,7 @@ 'subject': 'eval:("Module: %(module)s, Type: %(doc_type)s, Standard: %(standard)s")', 'tag_fields': 'doc_type', 'use_template': 0, - 'version': 24 + 'version': 25 }, # These values are common for all DocField @@ -99,7 +99,7 @@ 'no_copy': 0, 'oldfieldname': 'module', 'oldfieldtype': 'Select', - 'options': 'Module Def', + 'options': 'link:Module Def', 'print_hide': 0, 'report_hide': 0, 'reqd': 1, diff --git a/py/webnotes/defs_template.py b/py/webnotes/defs_template.py index 823edc0356..1b55c20cbf 100644 --- a/py/webnotes/defs_template.py +++ b/py/webnotes/defs_template.py @@ -116,3 +116,6 @@ backup_link_path = '/var/www/wnframework/backups' # url to be emailed to the "System Manager" Role to download # the backup backup_url = 'http://localhost/backups' + +# System TimeZone (should be acceptable by pytz: Recommended format Continent/City) +system_timezone = 'Asia/Kolkata' diff --git a/py/webnotes/utils/email_lib/__init__.py b/py/webnotes/utils/email_lib/__init__.py index 7d0572d46b..4497055786 100644 --- a/py/webnotes/utils/email_lib/__init__.py +++ b/py/webnotes/utils/email_lib/__init__.py @@ -19,7 +19,7 @@ def make_html_body(content, template = None): return template_html % {'content': content} -def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc=[], attach=[], send_now=1, reply_to=None, template=None): +def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc=[], attach=[], send_now=1, reply_to=None, template=None, from_defs=0): """ send an html email as multipart with attachments and all """ @@ -27,7 +27,7 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc from webnotes.utils.email_lib.html2text import html2text from webnotes.utils.email_lib.send import EMail - email = EMail(sender, recipients, subject, reply_to=reply_to) + email = EMail(sender, recipients, subject, reply_to=reply_to, from_defs=from_defs) email.cc = cc if msg: diff --git a/py/webnotes/utils/email_lib/send.py b/py/webnotes/utils/email_lib/send.py index 52e4572459..b6c01d04df 100644 --- a/py/webnotes/utils/email_lib/send.py +++ b/py/webnotes/utils/email_lib/send.py @@ -138,6 +138,7 @@ class EMail: setup the SMTP (outgoing) server from `Control Panel` or defs.py """ if self.from_defs: + import webnotes self.server = getattr(webnotes.defs,'mail_server','') self.login = getattr(webnotes.defs,'mail_login','') self.port = getattr(webnotes.defs,'mail_port',None) From e266c6ba29f54bf0b2ad761dfeb53f1aaca24f0a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 13 Dec 2011 19:30:43 +0530 Subject: [PATCH 2/2] Changes in logic of print format to display draft in page header --- js/legacy/form.compressed.js | 3 ++- js/legacy/widgets/form/print_format.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/js/legacy/form.compressed.js b/js/legacy/form.compressed.js index 018aada167..bac624e57d 100644 --- a/js/legacy/form.compressed.js +++ b/js/legacy/form.compressed.js @@ -355,7 +355,8 @@ var doc=locals[cur_frm.doctype][cur_frm.docname];if(args.fmtname=='Standard'){ar {{HEAD}}\ \ {{DESCRIPTION}}\ - "},show_draft:function(args){if(args.doc&&cint(args.doc.docstatus)==0&&cur_frm.perm[0][SUBMIT]){draft=_p.head_banner_format();draft=draft.replace("{{HEAD}}","DRAFT");draft=draft.replace("{{DESCRIPTION}}","This box will go away after the document is submitted.");return draft;}else{return"";}},show_archived:function(args){if(args.doc&&args.doc.__archived){archived=_p.head_banner_format();archived=archived.replace("{{HEAD}}","ARCHIVED");archived=archived.replace("{{DESCRIPTION}}","You must restore this document to make it editable.");}else{return"";}},consolidate_css:function(container,args){var body_style='';var style_list=container.getElementsByTagName('style');while(style_list&&style_list.length>0){for(i in style_list){if(style_list[i]&&style_list[i].innerHTML){body_style+=style_list[i].innerHTML;var parent=style_list[i].parentNode;if(parent){parent.removeChild(style_list[i]);}else{container.removeChild(style_list[i]);}}} + "},show_draft:function(args){var is_doctype_submittable=0;var plist=locals['DocPerm'];for(var perm in plist){var p=plist[perm];if((p.parent==args.doc.doctype)&&(p.submit==1)){is_doctype_submittable=1;break;}} +if(args.doc&&cint(args.doc.docstatus)==0&&is_doctype_submittable){draft=_p.head_banner_format();draft=draft.replace("{{HEAD}}","DRAFT");draft=draft.replace("{{DESCRIPTION}}","This box will go away after the document is submitted.");return draft;}else{return"";}},show_archived:function(args){if(args.doc&&args.doc.__archived){archived=_p.head_banner_format();archived=archived.replace("{{HEAD}}","ARCHIVED");archived=archived.replace("{{DESCRIPTION}}","You must restore this document to make it editable.");}else{return"";}},consolidate_css:function(container,args){var body_style='';var style_list=container.getElementsByTagName('style');while(style_list&&style_list.length>0){for(i in style_list){if(style_list[i]&&style_list[i].innerHTML){body_style+=style_list[i].innerHTML;var parent=style_list[i].parentNode;if(parent){parent.removeChild(style_list[i]);}else{container.removeChild(style_list[i]);}}} style_list=container.getElementsByTagName('style');} style_concat=(args.only_body?'':_p.def_print_style_body) +_p.def_print_style_other+args.style+body_style;return style_concat;},run_embedded_js:function(container,doc){var jslist=container.getElementsByTagName('script');while(jslist&&jslist.length>0){for(i in jslist){if(jslist[i]&&jslist[i].innerHTML){var code=jslist[i].innerHTML;var parent=jslist[i].parentNode;var span=$a(parent,'span');parent.replaceChild(span,jslist[i]);var val=code?eval(code):'';if(!val||typeof(val)=='object'){val='';} diff --git a/js/legacy/widgets/form/print_format.js b/js/legacy/widgets/form/print_format.js index a1077bb590..39f053bb26 100644 --- a/js/legacy/widgets/form/print_format.js +++ b/js/legacy/widgets/form/print_format.js @@ -189,7 +189,17 @@ $.extend(_p, { Display draft in header if true */ show_draft: function(args) { - if(args.doc && cint(args.doc.docstatus)==0 && cur_frm.perm[0][SUBMIT]) { + var is_doctype_submittable = 0; + var plist = locals['DocPerm']; + for(var perm in plist) { + var p = plist[perm]; + if((p.parent==args.doc.doctype) && (p.submit==1)){ + is_doctype_submittable = 1; + break; + } + } + + if(args.doc && cint(args.doc.docstatus)==0 && is_doctype_submittable) { draft = _p.head_banner_format(); draft = draft.replace("{{HEAD}}", "DRAFT"); draft = draft.replace("{{DESCRIPTION}}", "This box will go away after the document is submitted.");