[CalendarServer-changes] [14478] CalendarServer/branches/users/sagen/trashcan-5/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 26 17:40:13 PST 2015
Revision: 14478
http://trac.calendarserver.org//changeset/14478
Author: sagen at apple.com
Date: 2015-02-26 17:40:13 -0800 (Thu, 26 Feb 2015)
Log Message:
-----------
Checkpoint, still working on attendee trash
Modified Paths:
--------------
CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py
CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py 2015-02-25 19:06:11 UTC (rev 14477)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/scheduling/processing.py 2015-02-27 01:40:13 UTC (rev 14478)
@@ -517,6 +517,21 @@
# Update the attendee's copy of the event
log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:REQUEST, UID: '%s' - updating event" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
+
+ # Only move from trash if attendee is not fully declined:
+ isTrash = yield self.recipient_calendar_resource.isTrash()
+ print("XYZZY is trash?", self.recipient_calendar_resource, self.recipient_calendar_resource._parentCollection, isTrash)
+ if isTrash:
+ print("XYZZY MESSAGE", self.message)
+ attendees = self.message.getAttendeeProperties((self.recipient.cuaddr,))
+ print("ATTENDEES", attendees, attendees[0].parameterValue("PARTSTAT", "blah"))
+ if not all([attendee.parameterValue("PARTSTAT", "NEEDS-ACTION") == "DECLINED" for attendee in attendees]):
+ print("XYZZY fromTrash start", self.recipient_calendar_resource)
+ yield self.recipient_calendar_resource.fromTrash()
+ print("XYZZY fromTrash end", self.recipient_calendar_resource)
+ else:
+ print("ATTENDEE IS FULLY DECLINED")
+
new_resource = (yield self.writeCalendarResource(None, self.recipient_calendar_resource, new_calendar))
if send_reply:
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py 2015-02-25 19:06:11 UTC (rev 14477)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/caldav/datastore/sql.py 2015-02-27 01:40:13 UTC (rev 14478)
@@ -4919,7 +4919,6 @@
organizerAddress = yield calendarUserFromCalendarUserAddress(organizer, self._txn)
if organizerAddress.record.uid == uid:
- print("XYZZY ORGANIZER")
# If the ORGANIZER is moving the event from trash
splitter = iCalSplitter()
willSplit = splitter.willSplit(caldata)
@@ -4963,7 +4962,6 @@
else:
# If an ATTENDEE is moving the event from trash
- print("XYZZY ATTENDEE")
yield ImplicitScheduler().sendAttendeeReply(
self._txn,
self
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py 2015-02-25 19:06:11 UTC (rev 14477)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/sql.py 2015-02-27 01:40:13 UTC (rev 14478)
@@ -7523,8 +7523,24 @@
@inlineCallbacks
def fromTrash(self):
- trash = self._parentCollection
- self._parentCollection = yield trash.originalParentForResource(self)
+
+ # First make sure this is actually in the trash
+ isTrash = yield self.isTrash()
+ if not isTrash:
+ returnValue(None)
+
+ if self._parentCollection.isTrash():
+ # The parent is indeed the trash collection
+ trash = self._parentCollection
+ self._parentCollection = yield trash.originalParentForResource(self)
+ _ignore, newName = trash.parseName(self._name)
+ else:
+ # The parent is the original collection because it was retrieved
+ # via that parent, not the trash collection
+ home = self._parentCollection.viewerHome()
+ trash = yield home.childWithName("trash")
+ newName = self._name
+
yield self._updateIsTrashQuery.on(
self._txn, isTrash=False, trashed=None, resourceID=self._resourceID
)
@@ -7534,13 +7550,14 @@
self
)
)
- _ignored, self._name = trash.parseName(self._name)
+ self._name = newName
yield self._parentCollection.addedObjectResource(self)
yield self._parentCollection._insertRevision(self.name())
+
@classproperty
def _selectIsTrashQuery(cls):
obj = cls._objectSchema
Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py 2015-02-25 19:06:11 UTC (rev 14477)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py 2015-02-27 01:40:13 UTC (rev 14478)
@@ -972,6 +972,23 @@
END:VCALENDAR
""" % subs
+ data4 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:CHANGED!
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+END:VEVENT
+END:VCALENDAR
+""" % subs
+
+
# user01 invites user02
txn = self.store.newTransaction()
yield self._createResource(
@@ -1034,9 +1051,6 @@
resource = yield self._getResource(txn, "user01", "inbox", "")
yield resource.remove()
- # result = yield txn.execSQL("select * from calendar_object", [])
- # for row in result:
- # print("ROW", row)
# user02's copy is in the trash only, and still has ACCEPTED
resourceNames = yield self._getResourceNames(txn, "user02", "trash")
@@ -1050,8 +1064,16 @@
data = yield self._getResourceData(txn, "user02", "trash", "")
self.assertTrue("PARTSTAT=ACCEPTED" in data)
- print("user02 trash copy before user01 updates it", data)
+ # result = yield txn.execSQL("select * from calendar_object", [])
+ # for row in result:
+ # print("calendar object ROW", row)
+
+ # result = yield txn.execSQL("select * from calendar_metadata", [])
+ # for row in result:
+ # print("calendar ROW", row)
+
+
yield txn.commit()
# user01 makes a change to event while user02's copy is in the trash
@@ -1063,27 +1085,95 @@
yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
txn = self.store.newTransaction()
+
+ # result = yield txn.execSQL("select * from calendar_object", [])
+ # for row in result:
+ # print("ROW", row)
+
+ resourceNames = yield self._getResourceNames(txn, "user02", "trash")
+ self.assertEqual(len(resourceNames), 0)
+
+ resourceNames = yield self._getResourceNames(txn, "user02", "calendar")
+ self.assertEqual(len(resourceNames), 1)
+
+ resourceNames = yield self._getResourceNames(txn, "user02", "inbox")
+ self.assertEqual(len(resourceNames), 1)
+
+ data = yield self._getResourceData(txn, "user02", "calendar", "")
+ self.assertTrue("EMAIL=user02 at example.com;RSVP=TRUE" in data)
+
+ resource = yield self._getResource(txn, "user01", "inbox", "")
+ yield resource.remove()
+
+ yield txn.commit()
+
+ # yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # txn = self.store.newTransaction()
+
+ # result = yield txn.execSQL("select * from calendar_object", [])
+ # for row in result:
+ # print("ROW", row)
+ # resourceNames = yield self._getResourceNames(txn, "user02", "calendar")
+ # print ("user02 calendar again", resourceNames)
+ # yield txn.commit()
+
+ # user02 trashes event again
+ txn = self.store.newTransaction()
+ resource = yield self._getResource(txn, "user02", "calendar", "")
+ yield resource.remove()
+
+ yield txn.commit()
+
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # user01's calendar copy shows user02 declined
+ txn = self.store.newTransaction()
+
data = yield self._getResourceData(txn, "user01", "calendar", "test.ics")
- print("user01 calendar copy", data)
+ self.assertTrue("PARTSTAT=DECLINED" in data)
+ # user01's inbox copy also shows user02 declined
+ data = yield self._getResourceData(txn, "user01", "inbox", "")
+ self.assertTrue("PARTSTAT=DECLINED" in data)
+ resource = yield self._getResource(txn, "user01", "inbox", "")
+ yield resource.remove()
+
+ yield txn.commit()
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # user01 makes a SUMMARY change to event while user02's copy is in the trash
+ txn = self.store.newTransaction()
+
+ print("USER CHANGING SUMMARY")
+ yield self._updateResource(txn, "user01", "calendar", "test.ics", data4)
+ yield txn.commit()
+
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+
+ txn = self.store.newTransaction()
+
+ # result = yield txn.execSQL("select * from calendar_object", [])
+ # for row in result:
+ # print("ROW", row)
+
resourceNames = yield self._getResourceNames(txn, "user02", "trash")
- print ("user02 trash", resourceNames)
- data = yield self._getResourceData(txn, "user02", "trash", "")
- print("user02 trash copy", data)
+ self.assertEqual(len(resourceNames), 1)
-
resourceNames = yield self._getResourceNames(txn, "user02", "calendar")
- print ("user02 calendar", resourceNames)
+ self.assertEqual(len(resourceNames), 0)
- # FIXME: user02 calendar should have the event!
-
resourceNames = yield self._getResourceNames(txn, "user02", "inbox")
- print ("user02 inbox", resourceNames)
- data = yield self._getResourceData(txn, "user02", "inbox", "")
- print("user02 inbox copy", data)
+ self.assertEqual(len(resourceNames), 0)
+ data = yield self._getResourceData(txn, "user02", "trash", "")
+ print("User02 trash copy", data)
+ # self.assertTrue("EMAIL=user02 at example.com;RSVP=TRUE" in data)
+
yield txn.commit()
+# FIXME: we should have a test where after the attendee's copy is trashed, it is fully removed, then have the organizer make a SUMMARY change, then a time change
@inlineCallbacks
@@ -1825,6 +1915,8 @@
self.assertEqual(len(resourceNames), 1)
resourceNames = yield self._getResourceNames(txn, "user01", "inbox")
self.assertEqual(len(resourceNames), 1)
+ resource = yield self._getResource(txn, "user01", "inbox", "")
+ yield resource.remove()
# user02's copy is in the trash only, and still has ACCEPTED
resourceNames = yield self._getResourceNames(txn, "user02", "trash")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150226/1acf613c/attachment-0001.html>
More information about the calendarserver-changes
mailing list