summaryrefslogtreecommitdiffstats
path: root/pykolab/xml/event.py
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab/xml/event.py')
-rw-r--r--pykolab/xml/event.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 18eea3e..97a0511 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -32,6 +32,7 @@ class Event(object):
def __init__(self, from_ical="", from_string=""):
self._attendees = []
+ self._categories = []
if from_ical == "":
if from_string == "":
@@ -48,6 +49,53 @@ class Event(object):
self._attendees.append(attendee)
self.event.setAttendees(self._attendees)
+ def add_category(self, category):
+ self._categories.append(category)
+ self.event.setCategories(self._categories)
+
+ def add_exception_date(self, _datetime):
+ valid_datetime = False
+ if isinstance(_datetime, datetime.date):
+ valid_datetime = True
+
+ if isinstance(_datetime, datetime.datetime):
+ # If no timezone information is passed on, make it UTC
+ if _datetime.tzinfo == None:
+ _datetime = _datetime.replace(tzinfo=pytz.utc)
+
+ valid_datetime = True
+
+ if not valid_datetime:
+ raise InvalidEventDateError, _("Event start needs datetime.date or datetime.datetime instance")
+
+ (
+ year,
+ month,
+ day,
+ ) = (
+ _datetime.year,
+ _datetime.month,
+ _datetime.day,
+ )
+ if hasattr(_datetime, 'hour'):
+ (
+ hour,
+ minute,
+ second
+ ) = (
+ _datetime.hour,
+ _datetime.minute,
+ _datetime.second
+ )
+ _cdatetime = kolabformat.cDateTime(year, month, day, hour, minute, second)
+ else:
+ _cdatetime = kolabformat.cDateTime(year, month, day)
+
+ if hasattr(_datetime, "tzinfo"):
+ _cdatetime.setTimezone(_datetime.tzinfo.__str__())
+
+ self.event.addExceptionDate(_cdatetime)
+
def as_string_itip(self, method="REQUEST"):
cal = icalendar.Calendar()
cal.add(
@@ -194,6 +242,12 @@ class Event(object):
def get_attendees(self):
return self._attendees
+ def get_categories(self):
+ return self.event.categories()
+
+ def get_classification(self):
+ return self.classification()
+
def get_created(self):
_datetime = self.event.created()
@@ -218,6 +272,9 @@ class Event(object):
except ValueError:
result = datetime.datetime.now()
+ def get_description(self):
+ return self.event.description()
+
def get_end(self):
_datetime = self.event.end()
@@ -256,6 +313,9 @@ class Event(object):
else:
return datetime.datetime(year, month, day, hour, minute, second, tzinfo=_timezone)
+ def get_exception_dates(self):
+ return self.event.exceptionDates()
+
def get_ical_attendee(self):
# TODO: Formatting, aye? See also the example snippet:
#
@@ -477,6 +537,9 @@ class Event(object):
attendee.set_participant_status(status)
self.event.setAttendees(self._attendees)
+ def set_classification(self, classification):
+ self.event.setClassification(classification)
+
def set_created(self, _datetime=None):
if _datetime == None:
_datetime = datetime.datetime.now()
@@ -501,6 +564,9 @@ class Event(object):
kolabformat.cDateTime(year, month, day, hour, minute, second)
)
+ def set_description(self, description):
+ self.event.setDescription(description)
+
def set_dtstamp(self, _datetime):
(
year,
@@ -565,6 +631,10 @@ class Event(object):
self.event.setEnd(_cdatetime)
+ def set_exception_dates(self, _datetimes):
+ for _datetime in _datetimes:
+ self.add_exception_date(_datetime)
+
def set_from_ical(self, attr, value):
if attr == "dtend":
self.set_ical_dtend(value.dt)
@@ -698,6 +768,9 @@ class Event(object):
self.event.setLastModified(kolabformat.cDateTime(year, month, day, hour, minute, second))
+ def set_location(self, location):
+ self.event.setLocation(location)
+
def set_organizer(self, email, name=None):
contactreference = ContactReference(email)
if not name == None:
@@ -708,6 +781,9 @@ class Event(object):
def set_priority(self, priority):
self.event.setPriority(priority)
+ def set_recurrence(self, recurrence):
+ self.event.setRecurrenceRule(recurrence)
+
def set_start(self, _datetime):
valid_datetime = False