[CalendarServer-changes] [2799] CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 11 13:32:09 PDT 2008


Revision: 2799
          http://trac.macosforge.org/projects/calendarserver/changeset/2799
Author:   cdaboo at apple.com
Date:     2008-08-11 13:32:09 -0700 (Mon, 11 Aug 2008)
Log Message:
-----------
Handle Attendee deleting an event (=> reply with DECLINE to organizer).

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/itip.py
    CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/scheduling/implicit.py

Modified: CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/itip.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/itip.py	2008-08-11 20:31:13 UTC (rev 2798)
+++ CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/itip.py	2008-08-11 20:32:09 UTC (rev 2799)
@@ -962,7 +962,7 @@
         return itip
 
     @staticmethod
-    def generateAttendeeReply(original, attendee):
+    def generateAttendeeReply(original, attendee, force_decline=False):
 
         # Start with a copy of the original as we may have to modify bits of it
         itip = original.duplicate()
@@ -983,4 +983,15 @@
             "ORGANIZER",
             "ATTENDEE",
         ))
+        
+        # Now set each ATTENDEE's PARTSTAT to DECLINED
+        if force_decline:
+            attendeeProps = itip.getAttendeeProperties((attendee,))
+            assert attendeeProps, "Must have some matching ATTENDEEs"
+            for attendeeProp in attendeeProps:
+                if "PARTSTAT" in attendeeProp.params():
+                    attendeeProp.params()["PARTSTAT"][0] = "DECLINED"
+                else:
+                    attendeeProp.params()["PARTSTAT"] = ["DECLINED"]
+        
         return itip

Modified: CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/scheduling/implicit.py	2008-08-11 20:31:13 UTC (rev 2798)
+++ CalendarServer/branches/users/cdaboo/implicit-2660/twistedcaldav/scheduling/implicit.py	2008-08-11 20:32:09 UTC (rev 2799)
@@ -273,20 +273,23 @@
     def doImplicitAttendee(self):
 
         if self.deleting:
-            log.error("Attendee '%s' is not allowed to delete an organized event: UID:%s" % (self.attendeePrincipal, self.uid,))
-            raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
-
-        # Get the ORGANIZER's current copy of the calendar object
-        yield self.getOrganizersCopy()
-        assert self.organizer_calendar, "Must have the organizer's copy of an invite"
+            #log.error("Attendee '%s' is not allowed to delete an organized event: UID:%s" % (self.attendeePrincipal, self.uid,))
+            #raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
+            log.debug("Implicit - attendee '%s' is cancelling UID: '%s'" % (self.attendee, self.uid))
+            yield self.scheduleCancelWithOrganizer()
         
-        # Determine whether the current change is allowed
-        if self.isAttendeeChangeInsignificant():
-            log.debug("Implicit - attendee '%s' is updating UID: '%s' but change is not significant" % (self.attendee, self.uid))
-            return
+        else:
+            # Get the ORGANIZER's current copy of the calendar object
+            yield self.getOrganizersCopy()
+            assert self.organizer_calendar, "Must have the organizer's copy of an invite"
             
-        log.debug("Implicit - attendee '%s' is updating UID: '%s'" % (self.attendee, self.uid))
-        yield self.scheduleWithOrganizer()
+            # Determine whether the current change is allowed
+            if self.isAttendeeChangeInsignificant():
+                log.debug("Implicit - attendee '%s' is updating UID: '%s' but change is not significant" % (self.attendee, self.uid))
+                return
+                
+            log.debug("Implicit - attendee '%s' is updating UID: '%s'" % (self.attendee, self.uid))
+            yield self.scheduleWithOrganizer()
 
     @inlineCallbacks
     def getOrganizersCopy(self):
@@ -342,11 +345,25 @@
         itipmsg = iTipGenerator.generateAttendeeReply(self.calendar, self.attendee)
 
         # Send scheduling message
+        yield self.sendToOrganizer("REPLY", itipmsg)
 
+    @inlineCallbacks
+    def scheduleCancelWithOrganizer(self):
+
+        itipmsg = iTipGenerator.generateAttendeeReply(self.calendar, self.attendee, True)
+
+        # Send scheduling message
+        yield self.sendToOrganizer("CANCEL", itipmsg)
+
+    @inlineCallbacks
+    def sendToOrganizer(self, action, itipmsg):
+
+        # Send scheduling message
+
         # This is a local CALDAV scheduling operation.
         scheduler = CalDAVScheduler(self.request, self.resource)
 
         # Do the PUT processing
-        log.info("Implicit REPLY - attendee: '%s' to organizer: '%s', UID: '%s'" % (self.attendee, self.organizer, self.uid,))
+        log.info("Implicit %s - attendee: '%s' to organizer: '%s', UID: '%s'" % (action, self.attendee, self.organizer, self.uid,))
         response = (yield scheduler.doSchedulingViaPUT(self.attendee, (self.organizer,), itipmsg))
         self.handleSchedulingResponse(response, False)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080811/7b6452de/attachment-0001.html 


More information about the calendarserver-changes mailing list