diff options
author | Thomas Bruederli <bruederli@kolabsys.com> | 2014-11-19 21:27:09 -0500 |
---|---|---|
committer | Thomas Bruederli <bruederli@kolabsys.com> | 2014-11-19 21:27:09 -0500 |
commit | d49a7ea6c05521995afa8b73fcf0e638931f83d9 (patch) | |
tree | 0dba2a27ac7e09bd59ea01d789855f78c6daaa78 /wallace | |
parent | d65762d548ef3869db2947d7f74434708c0b0820 (diff) | |
download | pykolab-d49a7ea6c05521995afa8b73fcf0e638931f83d9.tar.gz |
Build iTip response and notification messages with unicode strings (#3926) + adjust tests
Diffstat (limited to 'wallace')
-rw-r--r-- | wallace/module_invitationpolicy.py | 20 | ||||
-rw-r--r-- | wallace/module_resources.py | 10 |
2 files changed, 22 insertions, 8 deletions
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py index 753547c..6adf82d 100644 --- a/wallace/module_invitationpolicy.py +++ b/wallace/module_invitationpolicy.py @@ -970,6 +970,10 @@ def send_update_notification(object, receiving_user, old=None, reply=True): from email.MIMEText import MIMEText from email.Utils import formatdate + # encode unicode strings with quoted-printable + from email import charset + charset.add_charset('utf-8', charset.SHORTEST, charset.QP) + organizer = object.get_organizer() orgemail = organizer.email() orgname = organizer.name() @@ -1053,12 +1057,12 @@ def send_update_notification(object, receiving_user, old=None, reply=True): message_text += "\n" + _("*** This is an automated message. Please do not reply. ***") # compose mime message - msg = MIMEText(utils.stripped_message(message_text)) + msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') msg['To'] = receiving_user['mail'] msg['Date'] = formatdate(localtime=True) - msg['Subject'] = _('"%s" has been updated') % (object.get_summary()) - msg['From'] = '"%s" <%s>' % (orgname, orgemail) if orgname else orgemail + msg['Subject'] = utils.str2unicode(_('"%s" has been updated') % (object.get_summary())) + msg['From'] = utils.str2unicode('"%s" <%s>' % (orgname, orgemail) if orgname else orgemail) smtp = smtplib.SMTP("localhost", 10027) @@ -1081,6 +1085,10 @@ def send_cancel_notification(object, receiving_user): from email.MIMEText import MIMEText from email.Utils import formatdate + # encode unicode strings with quoted-printable + from email import charset + charset.add_charset('utf-8', charset.SHORTEST, charset.QP) + log.debug(_("Send cancellation notification for %s %r to user %r") % ( object.type, object.uid, receiving_user['mail'] ), level=8) @@ -1111,12 +1119,12 @@ def send_cancel_notification(object, receiving_user): message_text += "\n" + _("*** This is an automated message. Please do not reply. ***") # compose mime message - msg = MIMEText(utils.stripped_message(message_text)) + msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') msg['To'] = receiving_user['mail'] msg['Date'] = formatdate(localtime=True) - msg['Subject'] = _('"%s" has been cancelled') % (object.get_summary()) - msg['From'] = '"%s" <%s>' % (orgname, orgemail) if orgname else orgemail + msg['Subject'] = utils.str2unicode(_('"%s" has been cancelled') % (object.get_summary())) + msg['From'] = utils.str2unicode('"%s" <%s>' % (orgname, orgemail) if orgname else orgemail) smtp = smtplib.SMTP("localhost", 10027) diff --git a/wallace/module_resources.py b/wallace/module_resources.py index 0b4d811..d1833eb 100644 --- a/wallace/module_resources.py +++ b/wallace/module_resources.py @@ -1197,6 +1197,10 @@ def send_owner_notification(resource, owner, itip_event, success=True): from email.MIMEText import MIMEText from email.Utils import formatdate + # encode unicode strings with quoted-printable + from email import charset + charset.add_charset('utf-8', charset.SHORTEST, charset.QP) + notify = False status = itip_event['xml'].get_attendee_by_email(resource['mail']).get_participant_status(True) @@ -1223,12 +1227,14 @@ def send_owner_notification(resource, owner, itip_event, success=True): message_text = owner_notification_text(resource, owner, itip_event['xml'], success) - msg = MIMEText(utils.stripped_message(message_text)) + msg = MIMEText(utils.stripped_message(message_text), _charset='utf-8') msg['To'] = owner['mail'] msg['From'] = resource['mail'] msg['Date'] = formatdate(localtime=True) - msg['Subject'] = _('Booking for %s has been %s') % (resource['cn'], participant_status_label(status) if success else _('failed')) + msg['Subject'] = utils.str2unicode(_('Booking for %s has been %s') % ( + resource['cn'], participant_status_label(status) if success else _('failed') + )) smtp = smtplib.SMTP("localhost", 10027) |