[CalendarServer-changes] [8254] CalendarServer/trunk/calendarserver/tools

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 2 09:44:49 PDT 2011


Revision: 8254
          http://trac.macosforge.org/projects/calendarserver/changeset/8254
Author:   sagen at apple.com
Date:     2011-11-02 09:44:49 -0700 (Wed, 02 Nov 2011)
Log Message:
-----------
Purge tool can now handle events without a "master" (i.e. when an attendee is invited to one or more occurrences of an event).

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/purge.py
    CalendarServer/trunk/calendarserver/tools/test/test_purge.py

Modified: CalendarServer/trunk/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/purge.py	2011-11-02 01:37:48 UTC (rev 8253)
+++ CalendarServer/trunk/calendarserver/tools/purge.py	2011-11-02 16:44:49 UTC (rev 8254)
@@ -541,19 +541,23 @@
     whenDate = when.duplicate()
     whenDate.setDateOnly(True)
 
-    master = event.masterComponent()
-
     # Only process VEVENT
-    if master.name() != "VEVENT":
+    if event.mainType() != "VEVENT":
         return CANCELEVENT_SKIPPED
 
+    main = event.masterComponent()
+    if main is None:
+        # No master component, so this is an attendee being invited to one or
+        # more occurrences
+        main = event.mainComponent(allow_multiple=True)
+
     # Anything completely in the future is deleted
-    dtstart = master.getStartDateUTC()
+    dtstart = main.getStartDateUTC()
     isDateTime = not dtstart.isDateOnly()
     if dtstart > when:
         return CANCELEVENT_SHOULD_DELETE
 
-    organizer = master.getOrganizer()
+    organizer = main.getOrganizer()
 
     # Non-meetings are deleted
     if organizer is None:
@@ -569,8 +573,8 @@
     dirty = False
 
     # Set the UNTIL on RRULE to cease at the cutoff
-    if master.hasProperty("RRULE"):
-        for rrule in master.properties("RRULE"):
+    if main.hasProperty("RRULE"):
+        for rrule in main.properties("RRULE"):
             rrule = rrule.value()
             if rrule.getUseCount():
                 rrule.setUseCount(False)
@@ -584,8 +588,8 @@
 
     # Remove any EXDATEs and RDATEs beyond the cutoff
     for dateType in ("EXDATE", "RDATE"):
-        if master.hasProperty(dateType):
-            for exdate_rdate in master.properties(dateType):
+        if main.hasProperty(dateType):
+            for exdate_rdate in main.properties(dateType):
                 newValues = []
                 for value in exdate_rdate.value():
                     if value.getValue() < when:
@@ -594,7 +598,7 @@
                         exdate_rdate.value().remove(value)
                         dirty = True
                 if not newValues:
-                    master.removeProperty(exdate_rdate)
+                    main.removeProperty(exdate_rdate)
                     dirty = True
 
 

Modified: CalendarServer/trunk/calendarserver/tools/test/test_purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_purge.py	2011-11-02 01:37:48 UTC (rev 8253)
+++ CalendarServer/trunk/calendarserver/tools/test/test_purge.py	2011-11-02 16:44:49 UTC (rev 8254)
@@ -258,7 +258,22 @@
             "urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
         self.assertEquals(action, CANCELEVENT_SHOULD_DELETE)
 
+    def test_cancelAsAttendeeOccurrence(self):
+        # A repeating meeting occurrence with no master, where purged CUA is
+        # an attendee
+        event = Component.fromString(INVITED_TO_OCCURRENCE_ICS)
+        action = cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
+            "urn:uuid:9DC04A71-E6DD-11DF-9492-0800200C9A66")
+        self.assertEquals(action, CANCELEVENT_SHOULD_DELETE)
 
+    def test_cancelAsAttendeeMultipleOccurrences(self):
+        # Multiple meeting occurrences with no master, where purged CUA is
+        # an attendee
+        event = Component.fromString(INVITED_TO_MULTIPLE_OCCURRENCES_ICS)
+        action = cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
+            "urn:uuid:9DC04A71-E6DD-11DF-9492-0800200C9A66")
+        self.assertEquals(action, CANCELEVENT_SHOULD_DELETE)
+
 # This event begins on Nov 30, 2010, has two EXDATES (Dec 3 and 9), and has two
 # overridden instances (Dec 4 and 11).  The Dec 11 one will be removed since
 # the cutoff date for this test is Dec 6.
@@ -607,3 +622,108 @@
 END:VEVENT
 END:VCALENDAR
 """.replace("\n", "\r\n")
+
+INVITED_TO_OCCURRENCE_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:REQUEST
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:America/Los_Angeles
+BEGIN:DAYLIGHT
+DTSTART:20070311T020000
+RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
+TZNAME:PDT
+TZOFFSETFROM:-0800
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+DTSTART:20071104T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
+TZNAME:PST
+TZOFFSETFROM:-0700
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:44A391CF-52F5-46B4-B35A-E000E3002084
+RECURRENCE-ID;TZID=America/Los_Angeles:20111103T150000
+DTSTART;TZID=America/Los_Angeles:20111103T150000
+DTEND;TZID=America/Los_Angeles:20111103T170000
+ATTENDEE;CN=Betty Test;CUTYPE=INDIVIDUAL;EMAIL=betty at example.com;PARTSTAT=
+ NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:urn:uuid:9DC04A71-E6DD-11DF-94
+ 92-0800200C9A66
+ATTENDEE;CN=Amanda Test;CUTYPE=INDIVIDUAL;EMAIL=amanda at example.com;PARTSTA
+ T=ACCEPTED:urn:uuid:9DC04A70-E6DD-11DF-9492-0800200C9A66
+CREATED:20111101T205355Z
+DTSTAMP:20111101T205506Z
+ORGANIZER;CN=Amanda Test;EMAIL=amanda at example.com:urn:uuid:9DC04A70-E6DD-1
+ 1DF-9492-0800200C9A66
+SEQUENCE:5
+SUMMARY:Repeating
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+
+INVITED_TO_MULTIPLE_OCCURRENCES_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:REQUEST
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:America/Los_Angeles
+BEGIN:DAYLIGHT
+DTSTART:20070311T020000
+RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
+TZNAME:PDT
+TZOFFSETFROM:-0800
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+DTSTART:20071104T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
+TZNAME:PST
+TZOFFSETFROM:-0700
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:44A391CF-52F5-46B4-B35A-E000E3002084
+RECURRENCE-ID;TZID=America/Los_Angeles:20111103T150000
+DTSTART;TZID=America/Los_Angeles:20111103T150000
+DTEND;TZID=America/Los_Angeles:20111103T170000
+ATTENDEE;CN=Betty Test;CUTYPE=INDIVIDUAL;EMAIL=betty at example.com;PARTSTAT=
+ NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:urn:uuid:9DC04A71-E6DD-11DF-94
+ 92-0800200C9A66
+ATTENDEE;CN=Amanda Test;CUTYPE=INDIVIDUAL;EMAIL=amanda at example.com;PARTSTA
+ T=ACCEPTED:urn:uuid:9DC04A70-E6DD-11DF-9492-0800200C9A66
+CREATED:20111101T205355Z
+DTSTAMP:20111101T205506Z
+ORGANIZER;CN=Amanda Test;EMAIL=amanda at example.com:urn:uuid:9DC04A70-E6DD-1
+ 1DF-9492-0800200C9A66
+SEQUENCE:5
+SUMMARY:Repeating
+TRANSP:OPAQUE
+END:VEVENT
+BEGIN:VEVENT
+ATTENDEE;CN="Amanda Test";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:9
+ DC04A70-E6DD-11DF-9492-0800200C9A66
+ATTENDEE;CN="Betty Test";CUTYPE=INDIVIDUAL;EMAIL="betty at example.com";PAR
+ TSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:betty at example.c
+ om
+DTEND;TZID=America/Los_Angeles:20111105T170000
+TRANSP:OPAQUE
+ORGANIZER;CN="Amanda Test":urn:uuid:9DC04A70-E6DD-11DF-9492-0800200C9A66
+ 
+UID:44A391CF-52F5-46B4-B35A-E000E3002084
+DTSTAMP:20111102T162426Z
+SEQUENCE:5
+RECURRENCE-ID;TZID=America/Los_Angeles:20111105T150000
+SUMMARY:Repeating
+DTSTART;TZID=America/Los_Angeles:20111105T150000
+CREATED:20111101T205355Z
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111102/ea590c1f/attachment.html>


More information about the calendarserver-changes mailing list