[CalendarServer-changes] [3370] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Nov 11 14:37:11 PST 2008
Revision: 3370
http://trac.macosforge.org/projects/calendarserver/changeset/3370
Author: sagen at apple.com
Date: 2008-11-11 14:37:11 -0800 (Tue, 11 Nov 2008)
Log Message:
-----------
Email date icons and templates now have an official home within /usr/share/caldavd; changing code to match
Modified Paths:
--------------
CalendarServer/trunk/locales/English.lproj/calendarserver.strings
CalendarServer/trunk/twistedcaldav/config.py
CalendarServer/trunk/twistedcaldav/localization.py
CalendarServer/trunk/twistedcaldav/mail.py
CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo
CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po
CalendarServer/trunk/twistedcaldav/test/test_localization.py
CalendarServer/trunk/twistedcaldav/test/test_mail.py
Modified: CalendarServer/trunk/locales/English.lproj/calendarserver.strings
===================================================================
--- CalendarServer/trunk/locales/English.lproj/calendarserver.strings 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/locales/English.lproj/calendarserver.strings 2008-11-11 22:37:11 UTC (rev 3370)
@@ -62,29 +62,29 @@
"December" = "December";
-"Jan" = "Jan";
+"JAN" = "JAN";
-"Feb" = "Feb";
+"FEB" = "FEB";
-"Mar" = "Mar";
+"MAR" = "MAR";
-"Apr" = "Apr";
+"APR" = "APR";
-"May" = "May";
+"MAY" = "MAY";
-"Jun" = "Jun";
+"JUN" = "JUN";
-"Jul" = "Jul";
+"JUL" = "JUL";
-"Aug" = "Aug";
+"AUG" = "AUG";
-"Sep" = "Sep";
+"SEP" = "SEP";
-"Oct" = "Oct";
+"OCT" = "OCT";
-"Nov" = "Nov";
+"NOV" = "NOV";
-"Dec" = "Dec";
+"DEC" = "DEC";
"Event canceled" = "Event canceled";
Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/config.py 2008-11-11 22:37:11 UTC (rev 3370)
@@ -270,8 +270,8 @@
"Password" : "", # For account receving mail
},
"AddressPatterns" : [], # Reg-ex patterns to match iMIP-able calendar user addresses
- "MailTemplatesDirectory": "/usr/share/caldavd/templates", # Directory containing HTML templates for email invitations (invite.html, cancel.html)
- "MailIconsDirectory": "/usr/share/caldavd/images/mail", # Directory containing language-specific subdirectories containing date-specific icons for email invitations (cal-icon-mm-dd.png)
+ "MailTemplatesDirectory": "/usr/share/caldavd/share/email_templates", # Directory containing HTML templates for email invitations (invite.html, cancel.html)
+ "MailIconsDirectory": "/usr/share/caldavd/share/date_icons", # Directory containing language-specific subdirectories containing date-specific icons for email invitations
"InvitationDaysToLive" : 90, # How many days invitations are valid
},
Modified: CalendarServer/trunk/twistedcaldav/localization.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/localization.py 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/localization.py 2008-11-11 22:37:11 UTC (rev 3370)
@@ -130,6 +130,9 @@
# Don't swallow exceptions
return False
+ def monthAbbreviation(self, monthNumber):
+ return self.translation.ugettext(monthsAbbrev[monthNumber])
+
def date(self, component):
dtStart = component.propertyNativeValue("DTSTART")
return self.dtDate(dtStart)
@@ -317,16 +320,16 @@
monthsAbbrev = [
"datetime.month is 1-based",
- _("Jan"),
- _("Feb"),
- _("Mar"),
- _("Apr"),
- _("May"),
- _("Jun"),
- _("Jul"),
- _("Aug"),
- _("Sep"),
- _("Oct"),
- _("Nov"),
- _("Dec"),
+ _("JAN"),
+ _("FEB"),
+ _("MAR"),
+ _("APR"),
+ _("MAY"),
+ _("JUN"),
+ _("JUL"),
+ _("AUG"),
+ _("SEP"),
+ _("OCT"),
+ _("NOV"),
+ _("DEC"),
]
Modified: CalendarServer/trunk/twistedcaldav/mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/mail.py 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/mail.py 2008-11-11 22:37:11 UTC (rev 3370)
@@ -772,19 +772,26 @@
deferred.addErrback(_failure, msgId, fromAddr, toAddr)
+ def getIconPath(self, details, language='en'):
+ month = int(details['month'])
+ day = int(details['day'])
+ iconDir = config.Scheduling.iMIP.MailIconsDirectory.rstrip("/")
+ with translationTo(language) as trans:
+ monthName = trans.monthAbbreviation(month)
+ iconName = "%02d.png" % (day,)
+ iconPath = os.path.join(iconDir, monthName, iconName)
+ if not os.path.exists(iconPath):
+ # Try the generic (numeric) version
+ iconPath = os.path.join(iconDir, "%02d" % (month,), iconName)
+ return iconPath
+
+
def generateEmail(self, newInvitation, calendar, orgEmail, orgCN,
attendees, fromAddress, replyToAddress, toAddress, language='en'):
details = self.getEventDetails(calendar, language=language)
+ iconPath = self.getIconPath(details, language=language)
- iconDir = config.Scheduling.iMIP.MailIconsDirectory.rstrip("/")
- iconName = "cal-icon-%02d-%02d.png" % (details['month'],
- details['day'])
- iconPath = os.path.join(iconDir, language, iconName)
- if not os.path.exists(iconPath):
- # Try the generic (numeric) version
- iconPath = os.path.join(iconDir, 'generic', iconName)
-
with translationTo(language):
msg = MIMEMultipart()
msg["From"] = fromAddress
@@ -886,7 +893,7 @@
else:
details['htmlOrganizer'] = orgCN
- details['iconName'] = iconName
+ details['iconName'] = iconName = "calicon.png"
templateDir = config.Scheduling.iMIP.MailTemplatesDirectory.rstrip("/")
templateName = "cancel.html" if canceled else "invite.html"
Modified: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo
===================================================================
(Binary files differ)
Modified: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po 2008-11-11 22:37:11 UTC (rev 3370)
@@ -144,8 +144,8 @@
msgstr "Ecemberday"
#: localization.py:273
-msgid "Jan"
-msgstr ""
+msgid "JAN"
+msgstr "ANJAY"
#: localization.py:274
msgid "Feb"
Modified: CalendarServer/trunk/twistedcaldav/test/test_localization.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_localization.py 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/test/test_localization.py 2008-11-11 22:37:11 UTC (rev 3370)
@@ -109,6 +109,8 @@
self.assertEquals(t.time(comp),
(u'11:05 AM PDT to 6:15 PM EDT', u'4 hours 10 minutes'))
+ self.assertEquals(t.monthAbbreviation(1), "JAN")
+
with translationTo('pig', localeDir=localeDir) as t:
comp = data[0][1]
@@ -135,3 +137,5 @@
comp = data[5][1]
self.assertEquals(t.time(comp),
(u'11:05 PDT otay 18:15 EDT', u'4 ourshay 10 inutesmay'))
+
+ self.assertEquals(t.monthAbbreviation(1), "ANJAY")
Modified: CalendarServer/trunk/twistedcaldav/test/test_mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_mail.py 2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/test/test_mail.py 2008-11-11 22:37:11 UTC (rev 3370)
@@ -30,6 +30,14 @@
self.handler = MailHandler(dataRoot=":memory:")
self.dataDir = os.path.join(os.path.dirname(__file__), "data", "mail")
+ def test_iconPath(self):
+ iconPath = self.handler.getIconPath({'day':'1', 'month':'1'}, language='en')
+ iconDir = "/usr/share/caldavd/share/date_icons"
+ if os.path.exists("%s/JAN/01.png" % (iconDir,)):
+ self.assertEquals(iconPath, "%s/JAN/01.png" % (iconDir,))
+ else:
+ self.assertEquals(iconPath, "%s/01/01.png" % (iconDir,))
+
def test_checkDSNFailure(self):
data = {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081111/e9298be1/attachment.html>
More information about the calendarserver-changes
mailing list