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

source_changes at macosforge.org source_changes at macosforge.org
Mon Jan 23 16:09:45 PST 2012


Revision: 8570
          http://trac.macosforge.org/projects/calendarserver/changeset/8570
Author:   sagen at apple.com
Date:     2012-01-23 16:09:45 -0800 (Mon, 23 Jan 2012)
Log Message:
-----------
Allow calendarserver_manage_principals to set auto schedule on users.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/principals.py
    CalendarServer/trunk/calendarserver/tools/test/test_principals.py

Modified: CalendarServer/trunk/calendarserver/tools/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/principals.py	2012-01-20 21:25:20 UTC (rev 8569)
+++ CalendarServer/trunk/calendarserver/tools/principals.py	2012-01-24 00:09:45 UTC (rev 8570)
@@ -676,7 +676,7 @@
 def action_setAutoSchedule(principal, autoSchedule):
     if principal.record.recordType == "groups":
         print "Enabling auto-schedule for %s is not allowed." % (principal,)
-        
+
     elif principal.record.recordType == "users" and not config.Scheduling.Options.AllowUserAutoAccept:
         print "Enabling auto-schedule for %s is not allowed." % (principal,)
 
@@ -807,13 +807,26 @@
         record = directory.createRecord(recordType, **kwargs)
         kwargs['guid'] = record.guid
     else:
-        record = directory.updateRecord(recordType, **kwargs)
+        try:
+            record = directory.updateRecord(recordType, **kwargs)
+        except NotImplementedError:
+            # Updating of directory information is not supported by underlying
+            # directory implementation, but allow augment information to be
+            # updated
+            record = directory.recordWithGUID(kwargs["guid"])
+            pass
 
     augmentService = directory.serviceForRecordType(recordType).augmentService
     augmentRecord = (yield augmentService.getAugmentRecord(kwargs['guid'], recordType))
     augmentRecord.autoSchedule = autoSchedule
     (yield augmentService.addAugmentRecords([augmentRecord]))
-    directory.updateRecord(recordType, **kwargs)
+    try:
+        directory.updateRecord(recordType, **kwargs)
+    except NotImplementedError:
+        # Updating of directory information is not supported by underlying
+        # directory implementation, but allow augment information to be
+        # updated
+        pass
 
     returnValue(record)
 

Modified: CalendarServer/trunk/calendarserver/tools/test/test_principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_principals.py	2012-01-20 21:25:20 UTC (rev 8569)
+++ CalendarServer/trunk/calendarserver/tools/test/test_principals.py	2012-01-24 00:09:45 UTC (rev 8570)
@@ -230,17 +230,22 @@
             "locations:location01")
         self.assertTrue(results.startswith('Autoschedule for "Room 01" (locations:location01) is true'))
 
+        results = yield self.runCommand("--set-auto-schedule=true",
+            "users:user01")
+        self.assertTrue(results.startswith('Enabling auto-schedule for (users)user01 is not allowed.'))
+
+
     @inlineCallbacks
     def test_updateRecord(self):
         directory = directoryFromConfig(config)
-        guid = "eee28807-a8c5-46c8-a558-a08281c558a7"
+        guid = "EEE28807-A8C5-46C8-A558-A08281C558A7"
 
         (yield updateRecord(True, directory, "locations",
-            guid=guid, fullName="Test User", shortNames=["testuser",],)
+            guid=guid, fullName="Test Location", shortNames=["testlocation",],)
         )
         try:
             (yield updateRecord(True, directory, "locations",
-                guid=guid, fullName="Test User", shortNames=["testuser",],)
+                guid=guid, fullName="Test Location", shortNames=["testlocation",],)
             )
         except DirectoryError:
             # We're expecting an error for trying to create a record with
@@ -251,11 +256,11 @@
 
         record = directory.recordWithGUID(guid)
         self.assertTrue(record is not None)
-        self.assertEquals(record.fullName, "Test User")
+        self.assertEquals(record.fullName, "Test Location")
         self.assertTrue(record.autoSchedule)
 
         (yield updateRecord(False, directory, "locations",
-            guid=guid, fullName="Changed", shortNames=["testuser",],)
+            guid=guid, fullName="Changed", shortNames=["testlocation",],)
         )
         record = directory.recordWithGUID(guid)
         self.assertTrue(record is not None)
@@ -265,6 +270,28 @@
         record = directory.recordWithGUID(guid)
         self.assertTrue(record is None)
 
+
+        # Create a user, change autoSchedule
+        guid = "F0DE73A8-39D4-4830-8D32-1FA03ABA3470"
+        (yield updateRecord(True, directory, "users",
+            guid=guid, fullName="Test User", shortNames=["testuser",],
+            autoSchedule=True)
+        )
+        record = directory.recordWithGUID(guid)
+        self.assertTrue(record is not None)
+        self.assertEquals(record.fullName, "Test User")
+        self.assertTrue(record.autoSchedule)
+
+        (yield updateRecord(False, directory, "users",
+            guid=guid, fullName="Test User", shortNames=["testuser",],
+            autoSchedule=False)
+        )
+        record = directory.recordWithGUID(guid)
+        self.assertTrue(record is not None)
+        self.assertEquals(record.fullName, "Test User")
+        self.assertFalse(record.autoSchedule)
+
+
     @inlineCallbacks
     def test_setProxies(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120123/d131935e/attachment.html>


More information about the calendarserver-changes mailing list