[CalendarServer-changes] [14682] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 15 20:59:52 PDT 2015


Revision: 14682
          http://trac.calendarserver.org//changeset/14682
Author:   sagen at apple.com
Date:     2015-04-15 20:59:52 -0700 (Wed, 15 Apr 2015)
Log Message:
-----------
Fix upgrading of older augments.xml

Modified Paths:
--------------
    CalendarServer/trunk/conf/auth/augments-test.xml
    CalendarServer/trunk/conf/auth/generate_test_accounts.py
    CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
    CalendarServer/trunk/twistedcaldav/upgrade.py
    CalendarServer/trunk/txdav/who/augment.py

Modified: CalendarServer/trunk/conf/auth/augments-test.xml
===================================================================
--- CalendarServer/trunk/conf/auth/augments-test.xml	2015-04-15 18:23:12 UTC (rev 14681)
+++ CalendarServer/trunk/conf/auth/augments-test.xml	2015-04-16 03:59:52 UTC (rev 14682)
@@ -25,13 +25,13 @@
     <enable-addressbook>true</enable-addressbook>
 </record>
 <record>
-    <uid>Default-Location</uid>
+    <uid>Location-Default</uid>
     <enable-calendar>true</enable-calendar>
     <enable-addressbook>true</enable-addressbook>
     <auto-schedule-mode>automatic</auto-schedule-mode>
 </record>
 <record>
-    <uid>Default-Resource</uid>
+    <uid>Resource-Default</uid>
     <enable-calendar>true</enable-calendar>
     <enable-addressbook>true</enable-addressbook>
     <auto-schedule-mode>automatic</auto-schedule-mode>

Modified: CalendarServer/trunk/conf/auth/generate_test_accounts.py
===================================================================
--- CalendarServer/trunk/conf/auth/generate_test_accounts.py	2015-04-15 18:23:12 UTC (rev 14681)
+++ CalendarServer/trunk/conf/auth/generate_test_accounts.py	2015-04-16 03:59:52 UTC (rev 14682)
@@ -960,7 +960,7 @@
 """)
 
 out.write("""<record>
-    <uid>Default-Location</uid>
+    <uid>Location-Default</uid>
     <enable-calendar>true</enable-calendar>
     <enable-addressbook>true</enable-addressbook>
     <auto-schedule-mode>automatic</auto-schedule-mode>
@@ -968,7 +968,7 @@
 """)
 
 out.write("""<record>
-    <uid>Default-Resource</uid>
+    <uid>Resource-Default</uid>
     <enable-calendar>true</enable-calendar>
     <enable-addressbook>true</enable-addressbook>
     <auto-schedule-mode>automatic</auto-schedule-mode>

Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2015-04-15 18:23:12 UTC (rev 14681)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2015-04-16 03:59:52 UTC (rev 14682)
@@ -1595,6 +1595,13 @@
     <auto-schedule>true</auto-schedule>
     <auto-schedule-mode>accept-if-free</auto-schedule-mode>
   </record>
+  <record>
+    <uid>B35DDFCF-C5E2-475E-A57E-8AB7422E9BB8</uid>
+    <enable>true</enable>
+    <enable-calendar>true</enable-calendar>
+    <enable-addressbook>true</enable-addressbook>
+    <auto-schedule>false</auto-schedule>
+  </record>
 </augments>
 """
 
@@ -1614,6 +1621,7 @@
     <enable-calendar>true</enable-calendar>
     <enable-addressbook>true</enable-addressbook>
     <enable-login>true</enable-login>
+    <auto-schedule-mode>automatic</auto-schedule-mode>
   </record>
   <record>
     <uid>60B771CC-D727-4453-ACE0-0FE13CD7445A</uid>
@@ -1636,6 +1644,12 @@
     <enable-login>true</enable-login>
     <auto-schedule-mode>accept-if-free</auto-schedule-mode>
   </record>
+  <record>
+    <uid>B35DDFCF-C5E2-475E-A57E-8AB7422E9BB8</uid>
+    <enable-calendar>true</enable-calendar>
+    <enable-addressbook>true</enable-addressbook>
+    <auto-schedule-mode>none</auto-schedule-mode>
+  </record>
 </augments>
 """
 

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2015-04-15 18:23:12 UTC (rev 14681)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2015-04-16 03:59:52 UTC (rev 14682)
@@ -45,7 +45,7 @@
 from twistedcaldav.directory.resourceinfo import ResourceInfoDatabase
 from twistedcaldav.directory.xmlaugmentsparser import ELEMENT_AUGMENTS
 from twistedcaldav.ical import Component
-from twistedcaldav.xmlutil import readXML, writeXML
+from twistedcaldav.xmlutil import readXML, writeXML, addSubElement
 
 from txdav.caldav.datastore.index_file import db_basename
 from txdav.caldav.datastore.scheduling.cuaddress import LocalCalendarUser
@@ -729,10 +729,17 @@
 
         autoScheduleElement = recordNode.find("auto-schedule")
         if autoScheduleElement is not None:
+            # This is a legacy augment record; if auto-schedule was true we
+            # need to set mode to "automatic", if false then set mode to "none".
+            # If auto-schedule was true and auto-schedule-mode existed, keep mode.
+
+            autoScheduleModeElement = recordNode.find("auto-schedule-mode")
+            if autoScheduleModeElement is None:
+                autoScheduleModeElement = addSubElement(recordNode, "auto-schedule-mode", text="automatic")
+
             if autoScheduleElement.text == "false":
-                autoScheduleModeElement = recordNode.find("auto-schedule-mode")
-                if autoScheduleModeElement is not None:
-                    autoScheduleModeElement.text = "none"
+                autoScheduleModeElement.text = "none"
+
             recordNode.remove(autoScheduleElement)
             changed = True
 

Modified: CalendarServer/trunk/txdav/who/augment.py
===================================================================
--- CalendarServer/trunk/txdav/who/augment.py	2015-04-15 18:23:12 UTC (rev 14681)
+++ CalendarServer/trunk/txdav/who/augment.py	2015-04-16 03:59:52 UTC (rev 14682)
@@ -407,6 +407,15 @@
                     augmentRecord.enabledForAddressBooks
                 )
 
+            # In the case of XML augments, a missing auto-schedule-mode
+            # element has the same meaning an element with a value of "default"
+            # in which case augmentRecord.autoScheduleMode = "default".  On
+            # the record we're augmenting, "default" mode means autoScheduleMode
+            # gets set to None (distinct from AutoScheduleMode.none!),
+            # which gets swapped for config.Scheduling.Options.AutoSchedule.DefaultMode
+            # in checkAttendeeAutoReply().
+            # ...Except for locations/resources which will default to automatic
+
             autoScheduleMode = {
                 "none": AutoScheduleMode.none,
                 "accept-always": AutoScheduleMode.accept,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150415/80bf265d/attachment.html>


More information about the calendarserver-changes mailing list