Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_resources.py
Show First 20 Lines • Show All 1,306 Lines • ▼ Show 20 Lines | def reservation_response_text(status, owner): | ||||
return message_text | return message_text | ||||
def send_owner_notification(resource, owner, itip_event, success=True): | def send_owner_notification(resource, owner, itip_event, success=True): | ||||
""" | """ | ||||
Send a reservation notification to the resource owner | Send a reservation notification to the resource owner | ||||
""" | """ | ||||
import smtplib | |||||
from pykolab import utils | from pykolab import utils | ||||
from email.MIMEText import MIMEText | from email.MIMEText import MIMEText | ||||
from email.Utils import formatdate | from email.Utils import formatdate | ||||
# encode unicode strings with quoted-printable | # encode unicode strings with quoted-printable | ||||
from email import charset | from email import charset | ||||
charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | charset.add_charset('utf-8', charset.SHORTEST, charset.QP) | ||||
Show All 27 Lines | if notify or not success: | ||||
msg['To'] = owner['mail'] | msg['To'] = owner['mail'] | ||||
msg['From'] = resource['mail'] | msg['From'] = resource['mail'] | ||||
msg['Date'] = formatdate(localtime=True) | msg['Date'] = formatdate(localtime=True) | ||||
msg['Subject'] = utils.str2unicode(_('Booking for %s has been %s') % ( | msg['Subject'] = utils.str2unicode(_('Booking for %s has been %s') % ( | ||||
resource['cn'], participant_status_label(status) if success else _('failed') | resource['cn'], participant_status_label(status) if success else _('failed') | ||||
)) | )) | ||||
smtp = smtplib.SMTP("localhost", 10027) | modules._sendmail(resource['mail'], owner['mail'], msg.as_string()) | ||||
if conf.debuglevel > 8: | |||||
smtp.set_debuglevel(True) | |||||
try: | |||||
smtp.sendmail(resource['mail'], owner['mail'], msg.as_string()) | |||||
except Exception, e: | |||||
log.error(_("SMTP sendmail error: %r") % (e)) | |||||
smtp.quit() | |||||
def owner_notification_text(resource, owner, event, success): | def owner_notification_text(resource, owner, event, success): | ||||
organizer = event.get_organizer() | organizer = event.get_organizer() | ||||
status = event.get_attendee_by_email(resource['mail']).get_participant_status(True) | status = event.get_attendee_by_email(resource['mail']).get_participant_status(True) | ||||
if success: | if success: | ||||
message_text = _(""" | message_text = _(""" | ||||
The resource booking for %(resource)s by %(orgname)s <%(orgemail)s> has been %(status)s for %(date)s. | The resource booking for %(resource)s by %(orgname)s <%(orgemail)s> has been %(status)s for %(date)s. | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |