diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 56478c139d..df30cb4e43 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -109,6 +109,7 @@ def init(site, sites_path=None): local.restrictions = None local.user_perms = {} local.test_objects = {} + local.jenv = None setup_module_map() @@ -544,11 +545,8 @@ def get_list(doctype, filters=None, fields=None, docstatus=None, group_by=group_by, order_by=order_by, limit_start=limit_start, limit_page_length=limit_page_length, as_list=as_list, debug=debug) -jenv = None - def get_jenv(): - global jenv - if not jenv: + if not local.jenv: from jinja2 import Environment, ChoiceLoader, PackageLoader, DebugUndefined import webnotes.utils @@ -567,7 +565,9 @@ def get_jenv(): "_": _ }) - return jenv + local.jenv = jenv + + return local.jenv def set_filters(jenv): from webnotes.utils import global_date_format diff --git a/webnotes/core/doctype/communication/communication.py b/webnotes/core/doctype/communication/communication.py index afc2e72d3d..8dce5ee0ee 100644 --- a/webnotes/core/doctype/communication/communication.py +++ b/webnotes/core/doctype/communication/communication.py @@ -37,7 +37,7 @@ def make(doctype=None, name=None, content=None, subject=None, sent_or_received = raise webnotes.PermissionError("You are not allowed to send emails related to: {doctype} {name}".format( doctype=doctype, name=name)) - _send(doctype=doctype, name=name, content=content, subject=subject, sent_or_received=sent_or_received, + _make(doctype=doctype, name=name, content=content, subject=subject, sent_or_received=sent_or_received, sender=sender, recipients=recipients, communication_medium=communication_medium, send_email=send_email, print_html=print_html, attachments=attachments, send_me_a_copy=send_me_a_copy, set_lead=set_lead, date=date) @@ -116,9 +116,13 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s d.content = sent_via.get_content(d) footer = set_portal_link(sent_via, d) - + + send_print_in_body = webnotes.conn.get_value("Email Settings", None, "send_print_in_body_and_attachment") + if not send_print_in_body: + d.content += "
Please see attachment for document details.
" + mail = get_email(d.recipients, sender=d.sender, subject=d.subject, - msg=d.content, footer=footer) + msg=d.content, footer=footer, print_html=print_html if send_print_in_body else None) if send_me_a_copy: mail.cc.append(webnotes.conn.get_value("Profile", webnotes.session.user, "email")) diff --git a/webnotes/core/doctype/profile/profile.py b/webnotes/core/doctype/profile/profile.py index 4b1216aa53..3fac8626fc 100644 --- a/webnotes/core/doctype/profile/profile.py +++ b/webnotes/core/doctype/profile/profile.py @@ -43,7 +43,7 @@ class DocType: pass # email server not set, don't send email self.doc.new_password = "" - + self.update_gravatar() def check_enable_disable(self): # do not allow disabling administrator/guest @@ -106,6 +106,15 @@ class DocType: # owner is always name webnotes.conn.set(self.doc, 'owner', self.doc.name) webnotes.clear_cache(user=self.doc.name) + + def update_gravatar(self): + import md5 + if not self.doc.user_image: + if self.doc.fb_username: + self.doc.user_image = "https://graph.facebook.com/" + self.doc.fb_username + "/picture" + else: + self.doc.user_image = "https://secure.gravatar.com/avatar/" + md5.md5(self.doc.name).hexdigest() \ + + "?d=retro" def reset_password(self): from webnotes.utils import random_string, get_url diff --git a/webnotes/core/page/setup/setup.txt b/webnotes/core/page/setup/setup.txt index faf64a661d..3978b77034 100644 --- a/webnotes/core/page/setup/setup.txt +++ b/webnotes/core/page/setup/setup.txt @@ -2,7 +2,7 @@ { "creation": "2012-06-14 15:07:28", "docstatus": 0, - "modified": "2014-02-07 14:48:08", + "modified": "2014-02-07 14:50:08", "modified_by": "Administrator", "owner": "Administrator" }, diff --git a/webnotes/hooks.txt b/webnotes/hooks.txt index 02c550237b..1a57c2e015 100644 --- a/webnotes/hooks.txt +++ b/webnotes/hooks.txt @@ -31,6 +31,7 @@ scheduler_event = all:webnotes.utils.email_lib.bulk.flush scheduler_event = daily:webnotes.utils.email_lib.bulk.clear_outbox scheduler_event = daily:webnotes.core.doctype.notification_count.notification_count.delete_event_notification_count scheduler_event = daily:webnotes.core.doctype.event.event.send_event_digest +scheduler_event = hourly:webnotes.templates.generator.website_group.clear_event_cache on_session_creation = webnotes.auth.notify_administrator_login diff --git a/webnotes/public/js/wn/views/communication.js b/webnotes/public/js/wn/views/communication.js index 012f9fde10..d46013def1 100644 --- a/webnotes/public/js/wn/views/communication.js +++ b/webnotes/public/js/wn/views/communication.js @@ -274,22 +274,13 @@ wn.views.CommunicationComposer = Class.extend({ }); }, - send_email: function(btn, form_values, selected_attachments, print_format_html) { + send_email: function(btn, form_values, selected_attachments, print_html) { var me = this; - if(form_values.attach_document_print) { - var print_html = print_format_html; - if(cint(wn.boot.send_print_in_body_and_attachment)) { - form_values.content = form_values.content - + "" - + "Please see attachment for document details.
" - } - } else { - var print_html = ""; + if(!form_values.attach_document_print) { + print_html = ""; } - + if(form_values.send_email) { if(cur_frm && !wn.model.can_email(me.doc.doctype, cur_frm)) { msgprint(wn._("You are not allowed to send emails related to this document.")); diff --git a/webnotes/templates/base.html b/webnotes/templates/base.html index 2014fa00e7..49a4ec9e40 100644 --- a/webnotes/templates/base.html +++ b/webnotes/templates/base.html @@ -60,7 +60,12 @@