[CalendarServer-changes] [13703] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sun Jun 29 17:39:56 PDT 2014


Revision: 13703
          http://trac.calendarserver.org//changeset/13703
Author:   cdaboo at apple.com
Date:     2014-06-29 17:39:56 -0700 (Sun, 29 Jun 2014)
Log Message:
-----------
Make sure attendees can EXDATE an invite that the organizer has deleted.

Modified Paths:
--------------
    CalendarServer/trunk/requirements-dev.txt
    CalendarServer/trunk/twistedcaldav/datafilters/hiddeninstance.py
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/storebridge.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py

Modified: CalendarServer/trunk/requirements-dev.txt
===================================================================
--- CalendarServer/trunk/requirements-dev.txt	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/requirements-dev.txt	2014-06-30 00:39:56 UTC (rev 13703)
@@ -7,4 +7,4 @@
 mockldap
 q
 --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@13420#egg=CalDAVClientLibrary
---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@13695#egg=CalDAVTester
+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@13702#egg=CalDAVTester

Modified: CalendarServer/trunk/twistedcaldav/datafilters/hiddeninstance.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/datafilters/hiddeninstance.py	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/twistedcaldav/datafilters/hiddeninstance.py	2014-06-30 00:39:56 UTC (rev 13703)
@@ -15,7 +15,7 @@
 ##
 
 from twistedcaldav.datafilters.filter import CalendarFilter
-from twistedcaldav.ical import Component, ignoredComponents, Property
+from twistedcaldav.ical import Component, ignoredComponents
 
 __all__ = [
     "HiddenInstanceFilter",
@@ -50,10 +50,7 @@
 
                 # Add EXDATE and try to preserve same timezone as DTSTART
                 if master is not None:
-                    dtstart = master.getProperty("DTSTART")
-                    if dtstart is not None and not dtstart.value().isDateOnly() and dtstart.value().local():
-                        rid.adjustTimezone(dtstart.value().getTimezone())
-                    master.addProperty(Property("EXDATE", [rid, ]))
+                    master.addExdate(rid)
 
         return ical
 

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2014-06-30 00:39:56 UTC (rev 13703)
@@ -1708,6 +1708,21 @@
         return rid in new_rids
 
 
+    def addExdate(self, exdate):
+        """
+        Add an EXDATE to a master recurring component and ensure the value type, TZID
+        etc match the DTSTART of the master. This method assumes that L{self} is the
+        master component - no checking of that will be done.
+
+        @param exdate: the exdate to add
+        @type exdate: L{DateTime}
+        """
+        dtstart = self.getProperty("DTSTART")
+        if dtstart is not None and not dtstart.value().isDateOnly() and dtstart.value().local():
+            exdate.adjustTimezone(dtstart.value().getTimezone())
+        self.addProperty(Property("EXDATE", [exdate, ]))
+
+
     def resourceUID(self):
         """
         @return: the UID of the subcomponents in this component.

Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py	2014-06-30 00:39:56 UTC (rev 13703)
@@ -2888,7 +2888,7 @@
             except ResourceDeletedError:
                 # This is OK - it just means the server deleted the resource during the PUT. We make it look
                 # like the PUT succeeded.
-                response = responsecode.CREATED if self.exists() else responsecode.NO_CONTENT
+                response = responsecode.NO_CONTENT if self.exists() else responsecode.CREATED
 
                 # Re-initialize to get stuff setup again now we have no object
                 self._initializeWithObject(None, self._newStoreParent)
@@ -3622,7 +3622,7 @@
             except ResourceDeletedError:
                 # This is OK - it just means the server deleted the resource during the PUT. We make it look
                 # like the PUT succeeded.
-                response = responsecode.CREATED if self.exists() else responsecode.NO_CONTENT
+                response = responsecode.NO_CONTENT if self.exists() else responsecode.CREATED
 
                 # Re-initialize to get stuff setup again now we have no object
                 self._initializeWithObject(None, self._newStoreParent)

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2014-06-30 00:39:56 UTC (rev 13703)
@@ -5673,6 +5673,93 @@
                 self.fail("Valid calendar should validate")
 
 
+
+
+    def test_add_exdate(self):
+        data = ((
+            """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//iCal 3.0//EN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:STANDARD
+DTSTART:20071104T020000
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+TZNAME:PST
+TZOFFSETFROM:-0700
+TZOFFSETTO:-0800
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20070311T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+TZNAME:PDT
+TZOFFSETFROM:-0800
+TZOFFSETTO:-0700
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:FB81D520-ED27-4DBA-8894-45B7612A7621
+DTSTART;TZID=US/Pacific:20090705T100000
+DTEND;TZID=US/Pacific:20090730T103000
+CREATED:20090604T225706Z
+DTSTAMP:20090604T230500Z
+RRULE:FREQ=DAILY
+SEQUENCE:1
+SUMMARY:TEST
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+""",
+            (
+                DateTime(2009, 7, 6, 17, 0, 0, tzid=Timezone(utc=True)),
+                DateTime(2009, 7, 6, 10, 0, 0, tzid=Timezone(tzid="US/Pacific")),
+            ),
+
+            """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//iCal 3.0//EN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:STANDARD
+DTSTART:20071104T020000
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+TZNAME:PST
+TZOFFSETFROM:-0700
+TZOFFSETTO:-0800
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20070311T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+TZNAME:PDT
+TZOFFSETFROM:-0800
+TZOFFSETTO:-0700
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:FB81D520-ED27-4DBA-8894-45B7612A7621
+DTSTART;TZID=US/Pacific:20090705T100000
+DTEND;TZID=US/Pacific:20090730T103000
+CREATED:20090604T225706Z
+DTSTAMP:20090604T230500Z
+EXDATE;TZID=US/Pacific:20090706T100000
+RRULE:FREQ=DAILY
+SEQUENCE:1
+SUMMARY:TEST
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+""",
+        ))
+
+        for exdate in data[1]:
+            calendar = Component.fromString(data[0])
+            result = Component.fromString(data[2])
+            calendar.masterComponent().addExdate(exdate)
+            self.assertEqual(normalize_iCalStr(calendar), normalize_iCalStr(result), "Failed exdate add: {}".format(exdate))
+
+
     def test_allperuseruids(self):
         data = """BEGIN:VCALENDAR
 VERSION:2.0

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py	2014-06-30 00:39:56 UTC (rev 13703)
@@ -1556,9 +1556,13 @@
                 if doScheduling:
                     # Check to see whether all instances are CANCELLED
                     if self.calendar.hasPropertyValueInAllComponents(Property("STATUS", "CANCELLED")):
-                        log.debug("Attendee '{attendee}' is creating CANCELLED event for missing UID: '{uid}' - removing entire event", attendee=self.attendee, uid=self.uid)
-                        self.return_status = ImplicitScheduler.STATUS_ORPHANED_CANCELLED_EVENT
-                        returnValue(None)
+                        if self.action == "create":
+                            log.debug("Attendee '{attendee}' is creating CANCELLED event for missing UID: '{uid}' - removing entire event", attendee=self.attendee, uid=self.uid)
+                            self.return_status = ImplicitScheduler.STATUS_ORPHANED_CANCELLED_EVENT
+                            returnValue(None)
+                        else:
+                            log.debug("Attendee '{attendee}' is modifying CANCELLED event for missing UID: '{uid}'", attendee=self.attendee, uid=self.uid)
+                            returnValue(None)
                     else:
                         # Check to see whether existing event is SCHEDULE-AGENT=CLIENT/NONE
                         if self.oldcalendar:

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py	2014-06-30 00:38:21 UTC (rev 13702)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py	2014-06-30 00:39:56 UTC (rev 13703)
@@ -309,7 +309,8 @@
 
         # If we have any EXDATEs lets add them to the existing calendar object.
         if exdates and calendar_master:
-            calendar_master.addProperty(Property("EXDATE", exdates))
+            for exdate in exdates:
+                calendar_master.addExdate(exdate)
 
         # See if there are still components in the calendar - we might have deleted the last overridden instance
         # in which case the calendar object is empty (except for VTIMEZONEs) or has only hidden components.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140629/4472dc10/attachment-0001.html>


More information about the calendarserver-changes mailing list