[CalendarServer-changes] [14939] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 1 17:53:00 PDT 2015
Revision: 14939
http://trac.calendarserver.org//changeset/14939
Author: sagen at apple.com
Date: 2015-07-01 17:53:00 -0700 (Wed, 01 Jul 2015)
Log Message:
-----------
Update structured location property value if it's changed
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-07-01 16:32:03 UTC (rev 14938)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-07-02 00:53:00 UTC (rev 14939)
@@ -3388,6 +3388,10 @@
sub.addProperty(structured)
else:
# Update existing one
+ prevGeo = structured.value()
+ if geo != prevGeo:
+ structured.setValue(geo)
+ changed = True
prevTitle = structured.parameterValue("X-TITLE")
for paramName, paramValue in params.iteritems():
prevValue = structured.parameterValue(paramName)
@@ -3421,6 +3425,7 @@
attendeeProp = sub.getAttendeeProperty((cuAddr,))
if attendeeProp is None: # ...remove it if no matching ATTENDEE
sub.removeProperty(structured)
+ changed = True
# Update the LOCATION
newLocationValue = ";".join(existingLocations)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2015-07-01 16:32:03 UTC (rev 14938)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2015-07-02 00:53:00 UTC (rev 14939)
@@ -3070,7 +3070,78 @@
yield self.commit()
+
@inlineCallbacks
+ def test_setComponent_structuredLocation_MissingValue(self):
+ """
+ Verify we detect a change to X-APPLE-STRUCTURED-LOCATION and update it.
+ (This also works if the client neglects to provide a value)
+ """
+
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
+BEGIN:VEVENT
+UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
+DTSTART:20131211T164500Z
+DURATION:PT1H
+ATTENDEE;CN=Room with Address 1;CUTYPE=ROOM;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPAN
+ T;SCHEDULE-STATUS=2.0:urn:x-uid:room-addr-1
+ATTENDEE;CN=User 01;CUTYPE=INDIVIDUAL;EMAIL=user01 at example.com;PARTSTAT=AC
+ CEPTED:urn:x-uid:user01
+X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-TITLE=Room with Address 1:
+CREATED:20131211T221854Z
+DTSTAMP:20131211T230632Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:x-uid:user01
+SEQUENCE:1
+SUMMARY:locations
+LOCATION:Room with Address 1
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ yield calendar.createCalendarObjectWithName(
+ "structured.ics",
+ Component.fromString(data)
+ )
+
+ yield self.commit()
+
+ cobj = yield self.calendarObjectUnderTest(
+ name="structured.ics",
+ calendar_name="calendar",
+ home="user01"
+ )
+ comp = yield cobj.componentForUser()
+ components = list(comp.subcomponents())
+
+ # Check first component -- LOCATION now has the street addresses, and
+ # location values that don't have an ATTENDEE or X-APPLE-STRUCTURED-LOCATIONs
+ # are retained
+ locProp = components[0].getProperty("LOCATION")
+ self.assertEquals(
+ locProp.value(),
+ "Room with Address 1\n1 Infinite Loop, Cupertino, CA 95014"
+ )
+ structProps = tuple(components[0].properties("X-APPLE-STRUCTURED-LOCATION"))
+ self.assertEqual(len(structProps), 1)
+ self.assertEquals(
+ structProps[0].value(),
+ "geo:37.331741,-122.030333",
+ )
+ # Make sure server has also added X-CUADDR
+ self.assertEquals(
+ structProps[0].parameterValue("X-CUADDR"),
+ "urn:x-uid:room-addr-1"
+ )
+
+ yield self.commit()
+
+
+ @inlineCallbacks
def test_setComponent_externalPrincipal(self):
"""
Verify attendees who are not locally hosted have X-APPLE-HOSTED-STATUS=EXTERNAL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150701/8c53f5f0/attachment.html>
More information about the calendarserver-changes
mailing list