Skip to content
Permalink
Browse files

Email date icons and templates now have an official home within /usr/…

…share/caldavd; changing code to match

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk@3370 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information...
m0rgen committed Nov 11, 2008
1 parent 59a79d0 commit c1fc263300087e2f19de4b91c81dc5894b27d73a
@@ -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";

@@ -270,8 +270,8 @@ def __getattr__(self, attr):
"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
},

@@ -130,6 +130,9 @@ def __exit__(self, type, value, traceback):
# 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 @@ def dtDuration(self, val):

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"),
]
@@ -772,18 +772,25 @@ def _failure(failure, msgId, fromAddr, toAddr):
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)

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)
iconPath = self.getIconPath(details, language=language)

with translationTo(language):
msg = MIMEMultipart()
@@ -886,7 +893,7 @@ def generateEmail(self, newInvitation, calendar, orgEmail, orgCN,
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"
Binary file not shown.
@@ -144,8 +144,8 @@ msgid "December"
msgstr "Ecemberday"

#: localization.py:273
msgid "Jan"
msgstr ""
msgid "JAN"
msgstr "ANJAY"

#: localization.py:274
msgid "Feb"
@@ -109,6 +109,8 @@ def test_CalendarFormatting(self):
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 @@ def test_CalendarFormatting(self):
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")
@@ -30,6 +30,14 @@ def setUp(self):
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 = {

0 comments on commit c1fc263

Please sign in to comment.
You can’t perform that action at this time.