summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-02-20 06:09:15 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2014-02-20 06:09:15 -0500
commitc1153b7c7214af35d7057f93592bb08d7de63f88 (patch)
tree10dc6d50371c74273e2ddf2a843d847849c8d070 /pykolab
parent4d460abbc06e0cc54f0a0b285708102829b618cc (diff)
downloadpykolab-c1153b7c7214af35d7057f93592bb08d7de63f88.tar.gz
Add the resource's common name when delegating; allow customized subject and text for iTip replies
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/xml/event.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 4f3ca0a..2dea819 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -153,25 +153,28 @@ class Event(object):
elif hasattr(cal, 'as_string'):
return cal.as_string()
- def delegate(self, delegators, delegatees):
+ def delegate(self, delegators, delegatees, names=None):
if not isinstance(delegators, list):
delegators = [delegators]
if not isinstance(delegatees, list):
delegatees = [delegatees]
+ if not isinstance(names, list):
+ names = [names]
+
_delegators = []
for delegator in delegators:
_delegators.append(self.get_attendee(delegator))
_delegatees = []
- for delegatee in delegatees:
+ for i,delegatee in enumerate(delegatees):
try:
_delegatees.append(self.get_attendee(delegatee))
except:
# TODO: An iTip needs to be sent out to the new attendee
- self.add_attendee(delegatee)
+ self.add_attendee(delegatee, names[i] if i < len(names) else None)
_delegatees.append(self.get_attendee(delegatee))
for delegator in _delegators:
@@ -916,7 +919,7 @@ class Event(object):
return msg
- def to_message_itip(self, from_address, method="REQUEST", participant_status="ACCEPTED"):
+ def to_message_itip(self, from_address, method="REQUEST", participant_status="ACCEPTED", subject=None, message_text=None):
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
@@ -979,19 +982,19 @@ class Event(object):
msg['Date'] = formatdate(localtime=True)
- # TODO: Should allow for localization
- text = utils.multiline_message("""
- This is a response to one of your event requests.
- """)
+ if subject is None:
+ subject = _("Reservation Request for %s was %s") % (self.get_summary(), participant_status)
- msg.attach( MIMEText(text) )
+ msg["Subject"] = subject
+
+ if message_text is None:
+ message_text = _("""This is an automated response to one of your event requests.""")
+
+ msg.attach(MIMEText(utils.multiline_message(message_text)))
part = MIMEBase('text', 'calendar', charset='UTF-8', method=method)
del part['MIME-Version'] # mime parts don't need this
- # TODO: Should allow for localization
- msg["Subject"] = "Meeting Request %s" % (participant_status)
-
part.set_payload(self.as_string_itip(method=method))
part.add_header('Content-Disposition', 'attachment; filename="event.ics"')