summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-07-10 04:35:36 -0400
committerThomas Bruederli <bruederli@kolabsys.com>2014-07-10 04:35:36 -0400
commit214bde4656f3e3a10096ba54dfa2704f4e8de719 (patch)
treef3e295f00a948cbe65b2e4f74616846d7ef6b439
parentd1f4cc6e05eea2f7d3b9e0a92ab0a2c5d10e926f (diff)
downloadpykolab-214bde4656f3e3a10096ba54dfa2704f4e8de719.tar.gz
New function to get a localized string for iCal participant status
-rw-r--r--pykolab/xml/__init__.py1
-rw-r--r--pykolab/xml/attendee.py20
-rw-r--r--pykolab/xml/event.py3
-rw-r--r--tests/unit/test-002-attendee.py7
4 files changed, 30 insertions, 1 deletions
diff --git a/pykolab/xml/__init__.py b/pykolab/xml/__init__.py
index 64b06ae..2bb42d4 100644
--- a/pykolab/xml/__init__.py
+++ b/pykolab/xml/__init__.py
@@ -1,5 +1,6 @@
from attendee import Attendee
from attendee import InvalidAttendeeParticipantStatusError
+from attendee import participant_status_label
from contact import Contact
from contact_reference import ContactReference
diff --git a/pykolab/xml/attendee.py b/pykolab/xml/attendee.py
index 579158e..220ab8c 100644
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -4,6 +4,26 @@ from pykolab.translate import _
from contact_reference import ContactReference
+participant_status_labels = {
+ "NEEDS-ACTION": _("Needs Action"),
+ "ACCEPTED": _("Accepted"),
+ "DECLINED": _("Declined"),
+ "TENTATIVE": _("Tentatively Accepted"),
+ "DELEGATED": _("Delegated"),
+ "COMPLETED": _("Completed"),
+ "IN-PROCESS": _("In Process"),
+ # support integer values, too
+ kolabformat.PartNeedsAction: _("Needs Action"),
+ kolabformat.PartAccepted: _("Accepted"),
+ kolabformat.PartDeclined: _("Declined"),
+ kolabformat.PartTentative: _("Tentatively Accepted"),
+ kolabformat.PartDelegated: _("Delegated"),
+ }
+
+def participant_status_label(status):
+ return participant_status_labels[status] if participant_status_labels.has_key(status) else status
+
+
class Attendee(kolabformat.Attendee):
cutype_map = {
"INDIVIDUAL": kolabformat.CutypeIndividual,
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 98a91aa..4ac4997 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -12,6 +12,7 @@ import pykolab
from pykolab import constants
from pykolab import utils
from pykolab.xml import utils as xmlutils
+from pykolab.xml import participant_status_label
from pykolab.translate import _
from os import path
@@ -928,7 +929,7 @@ class Event(object):
msg['Date'] = formatdate(localtime=True)
if subject is None:
- subject = _("Invitation for %s was %s") % (self.get_summary(), _(participant_status))
+ subject = _("Invitation for %s was %s") % (self.get_summary(), participant_status_label(participant_status))
msg["Subject"] = subject
diff --git a/tests/unit/test-002-attendee.py b/tests/unit/test-002-attendee.py
index 9da93c7..8bcee3c 100644
--- a/tests/unit/test-002-attendee.py
+++ b/tests/unit/test-002-attendee.py
@@ -1,7 +1,9 @@
import datetime
import unittest
+import kolabformat
from pykolab.xml import Attendee
+from pykolab.xml import participant_status_label
class TestEventXML(unittest.TestCase):
attendee = Attendee("jane@doe.org")
@@ -101,5 +103,10 @@ class TestEventXML(unittest.TestCase):
self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 2][0], "INDIVIDUAL")
self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 3][0], "RESOURCE")
+ def test_018_partstat_label(self):
+ self.assertEqual(participant_status_label('NEEDS-ACTION'), "Needs Action")
+ self.assertEqual(participant_status_label(kolabformat.PartTentative), "Tentatively Accepted")
+ self.assertEqual(participant_status_label('UNKNOWN'), "UNKNOWN")
+
if __name__ == '__main__':
unittest.main()