[CalendarServer-changes] [7884] CalendarServer/branches/users/glyph/imip-and-admin-html/ twistedcaldav/mail.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 11 21:37:08 PDT 2011
Revision: 7884
http://trac.macosforge.org/projects/calendarserver/changeset/7884
Author: glyph at apple.com
Date: 2011-08-11 21:37:08 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
move htmlAttendees and htmlOrganizer generation to renderHTML, as they're HTML
Modified Paths:
--------------
CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py 2011-08-12 04:36:57 UTC (rev 7883)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py 2011-08-12 04:37:08 UTC (rev 7884)
@@ -1276,25 +1276,11 @@
msgHtmlRelated = MIMEMultipart("related", type="text/html")
msgAlt.attach(msgHtmlRelated)
- htmlAttendees = []
- for cn, mailto in attendees:
- if mailto:
- htmlAttendees.append('<a href="mailto:%s">%s</a>' %
- (mailto, cn))
- else:
- htmlAttendees.append(cn)
-
- details['htmlAttendees'] = ", ".join(htmlAttendees)
-
- if orgEmail:
- details['htmlOrganizer'] = '<a href="mailto:%s">%s</a>' % (
- orgEmail, orgCN)
- else:
- details['htmlOrganizer'] = orgCN
-
details['iconName'] = iconName = "calicon.png"
- addIcon, htmlText = self.renderHTML(details, canceled)
+ addIcon, htmlText = self.renderHTML(
+ details, (orgCN, orgEmail), attendees, canceled
+ )
msgHtml = MIMEText(htmlText.encode("UTF-8"), "html", "UTF-8")
msgHtmlRelated.attach(msgHtml)
@@ -1326,7 +1312,7 @@
return msgId, msg.as_string()
- def renderHTML(self, details, canceled):
+ def renderHTML(self, details, organizer, attendees, canceled):
"""
Render HTML message part based on invitation details and a flag
indicating whether the message is a cancellation.
@@ -1335,7 +1321,30 @@
The first element indicates whether the MIME generator needs to add
a L{cid:} icon image part to satisfy the HTML links.
"""
+ orgCN, orgEmail = organizer
+ # TODO: htmlAttendees needs to be a separate element with a separate
+ # template fragment. Luckily that fragment is the same regardless
+ # of the rest of the template.
+ htmlAttendees = []
+ for cn, mailto in attendees:
+ if mailto:
+ htmlAttendees.append('<a href="mailto:%s">%s</a>' %
+ (mailto, cn))
+ else:
+ htmlAttendees.append(cn)
+
+ details['htmlAttendees'] = ", ".join(htmlAttendees)
+
+ # TODO: htmlOrganizer is also some HTML that requires additional
+ # template stuff, and once again, it's just a 'mailto:'.
+ # tags.a(href="mailto:"+email)[cn]
+ if orgEmail:
+ details['htmlOrganizer'] = '<a href="mailto:%s">%s</a>' % (
+ orgEmail, orgCN)
+ else:
+ details['htmlOrganizer'] = orgCN
+
templateDir = config.Scheduling.iMIP.MailTemplatesDirectory.rstrip("/")
templateName = "cancel.html" if canceled else "invite.html"
templatePath = os.path.join(templateDir, templateName)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110811/00e35636/attachment.html>
More information about the calendarserver-changes
mailing list