<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15755] CalendarServer/trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15755">15755</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2016-07-07 13:38:32 -0700 (Thu, 07 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Adds a new record.setAutoScheduleMode( ) method which csmp, web admin, and dps all use.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertoolsgatewaypy">CalendarServer/trunk/calendarserver/tools/gateway.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolsprincipalspy">CalendarServer/trunk/calendarserver/tools/principals.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolstesttest_principalspy">CalendarServer/trunk/calendarserver/tools/test/test_principals.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolsutilpy">CalendarServer/trunk/calendarserver/tools/util.py</a></li>
<li><a href="#CalendarServertrunkcalendarserverwebadmindelegationpy">CalendarServer/trunk/calendarserver/webadmin/delegation.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavicalendardirectoryservicepy">CalendarServer/trunk/txdav/caldav/icalendardirectoryservice.py</a></li>
<li><a href="#CalendarServertrunktxdavdpsclientpy">CalendarServer/trunk/txdav/dps/client.py</a></li>
<li><a href="#CalendarServertrunktxdavdpscommandspy">CalendarServer/trunk/txdav/dps/commands.py</a></li>
<li><a href="#CalendarServertrunktxdavdpsserverpy">CalendarServer/trunk/txdav/dps/server.py</a></li>
<li><a href="#CalendarServertrunktxdavdpstesttest_clientpy">CalendarServer/trunk/txdav/dps/test/test_client.py</a></li>
<li><a href="#CalendarServertrunktxdavwhoaugmentpy">CalendarServer/trunk/txdav/who/augment.py</a></li>
<li><a href="#CalendarServertrunktxdavwhodirectorypy">CalendarServer/trunk/txdav/who/directory.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_directorypy">CalendarServer/trunk/txdav/who/test/test_directory.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertoolsgatewaypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/gateway.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/gateway.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/calendarserver/tools/gateway.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -35,16 +35,14 @@
</span><span class="cx"> WRITABLE_CONFIG_KEYS, setKeyPath, getKeyPath, flattenDictionary,
</span><span class="cx"> WritableConfig
</span><span class="cx"> )
</span><del>-from calendarserver.tools.principals import (
- getProxies, setProxies
-)
</del><span class="cx"> from calendarserver.tools.purge import (
</span><span class="cx"> WorkerService, PurgeOldEventsService,
</span><span class="cx"> DEFAULT_BATCH_SIZE, DEFAULT_RETAIN_DAYS,
</span><span class="cx"> PrincipalPurgeWork
</span><span class="cx"> )
</span><span class="cx"> from calendarserver.tools.util import (
</span><del>- recordForPrincipalID, autoDisableMemcached
</del><ins>+ recordForPrincipalID, autoDisableMemcached,
+ getProxies, setProxies
</ins><span class="cx"> )
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> from twext.who.directory import DirectoryRecord
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolsprincipalspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/principals.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/principals.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/calendarserver/tools/principals.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx">
</span><span class="cx"> from calendarserver.tools.cmdline import utilityMain, WorkerService
</span><span class="cx"> from calendarserver.tools.util import (
</span><del>- recordForPrincipalID, prettyRecord
</del><ins>+ recordForPrincipalID, prettyRecord, action_addProxy, action_removeProxy
</ins><span class="cx"> )
</span><span class="cx"> from twext.who.directory import DirectoryRecord
</span><span class="cx"> from twext.who.idirectory import RecordType, InvalidDirectoryRecordError
</span><span class="lines">@@ -40,8 +40,7 @@
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue, succeed
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from twistedcaldav.cache import MemcacheChangeNotifier
</span><del>-from txdav.who.delegates import Delegates, RecordType as DelegateRecordType, \
- CachingDelegates
</del><ins>+from txdav.who.delegates import CachingDelegates
</ins><span class="cx"> from txdav.who.idirectory import AutoScheduleMode
</span><span class="cx"> from txdav.who.groups import GroupCacherPollingWork
</span><span class="cx">
</span><span class="lines">@@ -604,108 +603,11 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-@inlineCallbacks
-def _addRemoveProxy(msg, fn, store, record, proxyType, *proxyIDs):
- directory = store.directoryService()
- readWrite = (proxyType == "write")
- for proxyID in proxyIDs:
- proxyRecord = yield recordForPrincipalID(directory, proxyID)
- if proxyRecord is None:
- print("Invalid principal ID: %s" % (proxyID,))
- else:
- txn = store.newTransaction()
- yield fn(txn, record, proxyRecord, readWrite)
- yield txn.commit()
- print(
- "{msg} {proxy} as a {proxyType} proxy for {record}".format(
- msg=msg, proxy=prettyRecord(proxyRecord),
- proxyType=proxyType, record=prettyRecord(record)
- )
- )
</del><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-@inlineCallbacks
-def action_addProxy(store, record, proxyType, *proxyIDs):
- if config.GroupCaching.Enabled and config.GroupCaching.UseDirectoryBasedDelegates:
- if record.recordType in (
- record.service.recordType.location,
- record.service.recordType.resource,
- ):
- print("You are not allowed to add proxies for locations or resources via command line when their proxy assignments come from the directory service.")
- returnValue(None)
</del><span class="cx">
</span><del>- yield _addRemoveProxy("Added", Delegates.addDelegate, store, record, proxyType, *proxyIDs)
-
-
-
</del><span class="cx"> @inlineCallbacks
</span><del>-def action_removeProxy(store, record, *proxyIDs):
- if config.GroupCaching.Enabled and config.GroupCaching.UseDirectoryBasedDelegates:
- if record.recordType in (
- record.service.recordType.location,
- record.service.recordType.resource,
- ):
- print("You are not allowed to remove proxies for locations or resources via command line when their proxy assignments come from the directory service.")
- returnValue(None)
-
- # Write
- yield _addRemoveProxy("Removed", Delegates.removeDelegate, store, record, "write", *proxyIDs)
- # Read
- yield _addRemoveProxy("Removed", Delegates.removeDelegate, store, record, "read", *proxyIDs)
-
-
-
-@inlineCallbacks
-def setProxies(record, readProxyRecords, writeProxyRecords):
- """
- Set read/write proxies en masse for a record
- @param record: L{IDirectoryRecord}
- @param readProxyRecords: a list of records
- @param writeProxyRecords: a list of records
- """
-
- proxyTypes = [
- (DelegateRecordType.readDelegateGroup, readProxyRecords),
- (DelegateRecordType.writeDelegateGroup, writeProxyRecords),
- ]
- for recordType, proxyRecords in proxyTypes:
- if proxyRecords is None:
- continue
- proxyGroup = yield record.service.recordWithShortName(
- recordType, record.uid
- )
- yield proxyGroup.setMembers(proxyRecords)
-
-
-
-@inlineCallbacks
-def getProxies(record):
- """
- Returns a tuple containing the records for read proxies and write proxies
- of the given record
- """
-
- allProxies = {
- DelegateRecordType.readDelegateGroup: [],
- DelegateRecordType.writeDelegateGroup: [],
- }
- for recordType in allProxies.iterkeys():
- proxyGroup = yield record.service.recordWithShortName(
- recordType, record.uid
- )
- allProxies[recordType] = yield proxyGroup.members()
-
- returnValue(
- (
- allProxies[DelegateRecordType.readDelegateGroup],
- allProxies[DelegateRecordType.writeDelegateGroup]
- )
- )
-
-
-
-@inlineCallbacks
</del><span class="cx"> def action_listGroupMembers(store, record):
</span><span class="cx"> members = yield record.members()
</span><span class="cx"> if members:
</span><span class="lines">@@ -871,17 +773,10 @@
</span><span class="cx"> )
</span><span class="cx"> )
</span><span class="cx">
</span><del>- # Get original fields
- newFields = record.fields.copy()
</del><ins>+ yield record.setAutoScheduleMode(autoScheduleMode)
</ins><span class="cx">
</span><del>- # Set new values
- newFields[record.service.fieldName.autoScheduleMode] = autoScheduleMode
</del><span class="cx">
</span><del>- updatedRecord = DirectoryRecord(record.service, newFields)
- yield record.service.updateRecords([updatedRecord], create=False)
</del><span class="cx">
</span><del>-
-
</del><span class="cx"> @inlineCallbacks
</span><span class="cx"> def action_setAutoAcceptGroup(store, record, autoAcceptGroup):
</span><span class="cx"> if record.recordType == RecordType.group:
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolstesttest_principalspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/test/test_principals.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/test/test_principals.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/calendarserver/tools/test/test_principals.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -19,8 +19,11 @@
</span><span class="cx"> from twistedcaldav.stdconfig import config
</span><span class="cx"> from calendarserver.tools.principals import (
</span><span class="cx"> parseCreationArgs, matchStrings,
</span><del>- recordForPrincipalID, getProxies, setProxies
</del><ins>+ recordForPrincipalID
</ins><span class="cx"> )
</span><ins>+from calendarserver.tools.util import (
+ getProxies, setProxies
+)
</ins><span class="cx"> from twext.python.filepath import CachingFilePath as FilePath
</span><span class="cx"> from twisted.internet import reactor
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, Deferred, returnValue
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolsutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/util.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/util.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/calendarserver/tools/util.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -41,9 +41,6 @@
</span><span class="cx"> from twext.python.log import Logger
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx">
</span><del>-from txdav.xml import element as davxml
-
-
</del><span class="cx"> from twistedcaldav import memcachepool
</span><span class="cx"> from txdav.base.propertystore.base import PropertyName
</span><span class="cx"> from txdav.xml import element
</span><span class="lines">@@ -52,7 +49,9 @@
</span><span class="cx"> from twext.who.idirectory import RecordType
</span><span class="cx"> from txdav.who.idirectory import RecordType as CalRecordType
</span><span class="cx">
</span><ins>+from txdav.who.delegates import Delegates, RecordType as DelegateRecordType
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -343,129 +342,110 @@
</span><span class="cx"> raise ValueError("Invalid principal identifier: %s" % (principalID,))
</span><span class="cx">
</span><span class="cx">
</span><ins>+@inlineCallbacks
+def _addRemoveProxy(msg, fn, store, record, proxyType, *proxyIDs):
+ directory = store.directoryService()
+ readWrite = (proxyType == "write")
+ for proxyID in proxyIDs:
+ proxyRecord = yield recordForPrincipalID(directory, proxyID)
+ if proxyRecord is None:
+ print("Invalid principal ID: %s" % (proxyID,))
+ else:
+ txn = store.newTransaction()
+ yield fn(txn, record, proxyRecord, readWrite)
+ yield txn.commit()
+ print(
+ "{msg} {proxy} as a {proxyType} proxy for {record}".format(
+ msg=msg, proxy=prettyRecord(proxyRecord),
+ proxyType=proxyType, record=prettyRecord(record)
+ )
+ )
</ins><span class="cx">
</span><del>-def proxySubprincipal(principal, proxyType):
- return principal.getChild("calendar-proxy-" + proxyType)
</del><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> @inlineCallbacks
</span><del>-def action_addProxyPrincipal(rootResource, directory, store, principal, proxyType, proxyPrincipal):
- try:
- (yield addProxy(rootResource, directory, store, principal, proxyType, proxyPrincipal))
- print("Added %s as a %s proxy for %s" % (
- prettyPrincipal(proxyPrincipal), proxyType,
- prettyPrincipal(principal)))
- except ProxyError, e:
- print("Error:", e)
- except ProxyWarning, e:
- print(e)
</del><ins>+def action_addProxy(store, record, proxyType, *proxyIDs):
+ if config.GroupCaching.Enabled and config.GroupCaching.UseDirectoryBasedDelegates:
+ if record.recordType in (
+ record.service.recordType.location,
+ record.service.recordType.resource,
+ ):
+ print("You are not allowed to add proxies for locations or resources via command line when their proxy assignments come from the directory service.")
+ returnValue(None)
</ins><span class="cx">
</span><ins>+ yield _addRemoveProxy("Added", Delegates.addDelegate, store, record, proxyType, *proxyIDs)
</ins><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><del>-def action_removeProxyPrincipal(rootResource, directory, store, principal, proxyPrincipal, **kwargs):
- try:
- removed = (yield removeProxy(
- rootResource, directory, store,
- principal, proxyPrincipal, **kwargs
- ))
- if removed:
- print("Removed %s as a proxy for %s" % (
- prettyPrincipal(proxyPrincipal),
- prettyPrincipal(principal)))
- except ProxyError, e:
- print("Error:", e)
- except ProxyWarning, e:
- print(e)
</del><ins>+def action_removeProxy(store, record, *proxyIDs):
+ if config.GroupCaching.Enabled and config.GroupCaching.UseDirectoryBasedDelegates:
+ if record.recordType in (
+ record.service.recordType.location,
+ record.service.recordType.resource,
+ ):
+ print("You are not allowed to remove proxies for locations or resources via command line when their proxy assignments come from the directory service.")
+ returnValue(None)
</ins><span class="cx">
</span><ins>+ # Write
+ yield _addRemoveProxy("Removed", Delegates.removeDelegate, store, record, "write", *proxyIDs)
+ # Read
+ yield _addRemoveProxy("Removed", Delegates.removeDelegate, store, record, "read", *proxyIDs)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>-def addProxy(rootResource, directory, store, principal, proxyType, proxyPrincipal):
- proxyURL = proxyPrincipal.url()
</del><ins>+def setProxies(record, readProxyRecords, writeProxyRecords):
+ """
+ Set read/write proxies en masse for a record
+ @param record: L{IDirectoryRecord}
+ @param readProxyRecords: a list of records
+ @param writeProxyRecords: a list of records
+ """
</ins><span class="cx">
</span><del>- subPrincipal = yield proxySubprincipal(principal, proxyType)
- if subPrincipal is None:
- raise ProxyError(
- "Unable to edit %s proxies for %s\n" % (
- proxyType,
- prettyPrincipal(principal)
- )
</del><ins>+ proxyTypes = [
+ (DelegateRecordType.readDelegateGroup, readProxyRecords),
+ (DelegateRecordType.writeDelegateGroup, writeProxyRecords),
+ ]
+ for recordType, proxyRecords in proxyTypes:
+ if proxyRecords is None:
+ continue
+ proxyGroup = yield record.service.recordWithShortName(
+ recordType, record.uid
</ins><span class="cx"> )
</span><ins>+ yield proxyGroup.setMembers(proxyRecords)
</ins><span class="cx">
</span><del>- membersProperty = (yield subPrincipal.readProperty(davxml.GroupMemberSet, None))
</del><span class="cx">
</span><del>- for memberURL in membersProperty.children:
- if str(memberURL) == proxyURL:
- raise ProxyWarning("%s is already a %s proxy for %s" % (
- prettyPrincipal(proxyPrincipal), proxyType,
- prettyPrincipal(principal)))
</del><span class="cx">
</span><del>- else:
- memberURLs = list(membersProperty.children)
- memberURLs.append(davxml.HRef(proxyURL))
- membersProperty = davxml.GroupMemberSet(*memberURLs)
- (yield subPrincipal.writeProperty(membersProperty, None))
</del><ins>+@inlineCallbacks
+def getProxies(record):
+ """
+ Returns a tuple containing the records for read proxies and write proxies
+ of the given record
+ """
</ins><span class="cx">
</span><del>- proxyTypes = ["read", "write"]
- proxyTypes.remove(proxyType)
</del><ins>+ allProxies = {
+ DelegateRecordType.readDelegateGroup: [],
+ DelegateRecordType.writeDelegateGroup: [],
+ }
+ for recordType in allProxies.iterkeys():
+ proxyGroup = yield record.service.recordWithShortName(
+ recordType, record.uid
+ )
+ allProxies[recordType] = yield proxyGroup.members()
</ins><span class="cx">
</span><del>- yield action_removeProxyPrincipal(
- rootResource, directory, store,
- principal, proxyPrincipal, proxyTypes=proxyTypes
</del><ins>+ returnValue(
+ (
+ allProxies[DelegateRecordType.readDelegateGroup],
+ allProxies[DelegateRecordType.writeDelegateGroup]
+ )
</ins><span class="cx"> )
</span><span class="cx">
</span><del>- # Schedule work the PeerConnectionPool will pick up as overdue
- def groupPollNow(txn):
- from txdav.who.groups import GroupCacherPollingWork
- return GroupCacherPollingWork.reschedule(txn, 0, force=True)
- yield store.inTransaction("addProxy groupPollNow", groupPollNow)
</del><span class="cx">
</span><ins>+def proxySubprincipal(principal, proxyType):
+ return principal.getChild("calendar-proxy-" + proxyType)
</ins><span class="cx">
</span><span class="cx">
</span><del>-@inlineCallbacks
-def removeProxy(rootResource, directory, store, principal, proxyPrincipal, **kwargs):
- removed = False
- proxyTypes = kwargs.get("proxyTypes", ("read", "write"))
- for proxyType in proxyTypes:
- proxyURL = proxyPrincipal.url()
</del><span class="cx">
</span><del>- subPrincipal = yield proxySubprincipal(principal, proxyType)
- if subPrincipal is None:
- raise ProxyError(
- "Unable to edit %s proxies for %s\n" % (
- proxyType,
- prettyPrincipal(principal)
- )
- )
-
- membersProperty = (yield subPrincipal.readProperty(davxml.GroupMemberSet, None))
-
- memberURLs = [
- m for m in membersProperty.children
- if str(m) != proxyURL
- ]
-
- if len(memberURLs) == len(membersProperty.children):
- # No change
- continue
- else:
- removed = True
-
- membersProperty = davxml.GroupMemberSet(*memberURLs)
- (yield subPrincipal.writeProperty(membersProperty, None))
-
- if removed:
- # Schedule work the PeerConnectionPool will pick up as overdue
- def groupPollNow(txn):
- from txdav.who.groups import GroupCacherPollingWork
- return GroupCacherPollingWork.reschedule(txn, 0, force=True)
- yield store.inTransaction("removeProxy groupPollNow", groupPollNow)
- returnValue(removed)
-
-
-
</del><span class="cx"> def prettyPrincipal(principal):
</span><span class="cx"> return prettyRecord(principal.record)
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunkcalendarserverwebadmindelegationpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/webadmin/delegation.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/webadmin/delegation.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/calendarserver/webadmin/delegation.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -27,8 +27,8 @@
</span><span class="cx"> import urlparse
</span><span class="cx">
</span><span class="cx"> from calendarserver.tools.util import (
</span><del>- principalForPrincipalID, proxySubprincipal, action_addProxyPrincipal,
- action_removeProxyPrincipal
</del><ins>+ recordForPrincipalID, proxySubprincipal, action_addProxy,
+ action_removeProxy, principalForPrincipalID
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="lines">@@ -49,6 +49,15 @@
</span><span class="cx"> from twext.who.idirectory import RecordType
</span><span class="cx"> from txdav.who.idirectory import RecordType as CalRecordType, AutoScheduleMode
</span><span class="cx">
</span><ins>+allowedAutoScheduleModes = {
+ "default": None,
+ "none": AutoScheduleMode.none,
+ "accept-always": AutoScheduleMode.accept,
+ "decline-always": AutoScheduleMode.decline,
+ "accept-if-free": AutoScheduleMode.acceptIfFree,
+ "decline-if-busy": AutoScheduleMode.declineIfBusy,
+ "automatic": AutoScheduleMode.acceptIfFreeDeclineIfBusy,
+}
</ins><span class="cx">
</span><span class="cx"> class WebAdminPage(Element):
</span><span class="cx"> """
</span><span class="lines">@@ -221,8 +230,8 @@
</span><span class="cx"> self.principalResource = principalResource
</span><span class="cx"> self.adminResource = adminResource
</span><span class="cx"> self.proxySearch = proxySearch
</span><del>- record = principalResource.record
- tag.fillSlots(resourceTitle=recordTitle(record),
</del><ins>+ self.record = principalResource.record
+ tag.fillSlots(resourceTitle=recordTitle(self.record),
</ins><span class="cx"> resourceId=resourceId,
</span><span class="cx"> davPropertyName=davPropertyName,
</span><span class="cx"> proxySearch=proxySearch)
</span><span class="lines">@@ -283,9 +292,9 @@
</span><span class="cx"> Renderer which elides its tag for non-resource-type principals.
</span><span class="cx"> """
</span><span class="cx"> if (
</span><del>- self.principalResource.record.recordType.description != "user" and
- self.principalResource.record.recordType.description != "group" or
- self.principalResource.record.recordType.description == "user" and
</del><ins>+ self.record.recordType.description != "user" and
+ self.record.recordType.description != "group" or
+ self.record.recordType.description == "user" and
</ins><span class="cx"> config.Scheduling.Options.AutoSchedule.AllowUsers
</span><span class="cx"> ):
</span><span class="cx"> return tag
</span><span class="lines">@@ -293,99 +302,91 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def isAutoSchedule(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag if the resource
</span><span class="cx"> is auto-schedule.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is not AutoScheduleMode.none:
</del><ins>+ if self.record.autoScheduleMode is not AutoScheduleMode.none:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def isntAutoSchedule(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag if the resource
</span><span class="cx"> is not auto-schedule.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.none:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.none:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def autoScheduleModeNone(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag based on the resource
</span><span class="cx"> auto-schedule-mode.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.none:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.none:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def autoScheduleModeAcceptAlways(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag based on the resource
</span><span class="cx"> auto-schedule-mode.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.accept:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.accept:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def autoScheduleModeDeclineAlways(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag based on the resource
</span><span class="cx"> auto-schedule-mode.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.decline:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.decline:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def autoScheduleModeAcceptIfFree(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag based on the resource
</span><span class="cx"> auto-schedule-mode.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.acceptIfFree:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.acceptIfFree:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def autoScheduleModeDeclineIfBusy(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag based on the resource
</span><span class="cx"> auto-schedule-mode.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.declineIfBusy:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.declineIfBusy:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @renderer
</span><del>- @inlineCallbacks
</del><span class="cx"> def autoScheduleModeAutomatic(self, request, tag):
</span><span class="cx"> """
</span><span class="cx"> Renderer which sets the 'selected' attribute on its tag based on the resource
</span><span class="cx"> auto-schedule-mode.
</span><span class="cx"> """
</span><del>- if (yield self.principalResource.getAutoScheduleMode()) is AutoScheduleMode.acceptIfFreeDeclineIfBusy:
</del><ins>+ if self.record.autoScheduleMode is AutoScheduleMode.acceptIfFreeDeclineIfBusy:
</ins><span class="cx"> tag(selected='selected')
</span><del>- returnValue(tag)
</del><ins>+ return tag
</ins><span class="cx">
</span><span class="cx"> _matrix = None
</span><span class="cx">
</span><span class="lines">@@ -634,9 +635,9 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def resourceActions(self, request, principal):
</del><ins>+ def resourceActions(self, request, record):
</ins><span class="cx"> """
</span><del>- Take all actions on the given principal based on the given request.
</del><ins>+ Take all actions on the given record based on the given request.
</ins><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> def queryValue(arg):
</span><span class="lines">@@ -651,45 +652,32 @@
</span><span class="cx"> matches.append(key[len(arg):])
</span><span class="cx"> return matches
</span><span class="cx">
</span><del>- autoSchedule = queryValue("autoSchedule")
</del><span class="cx"> autoScheduleMode = queryValue("autoScheduleMode")
</span><span class="cx"> makeReadProxies = queryValues("mkReadProxy|")
</span><span class="cx"> makeWriteProxies = queryValues("mkWriteProxy|")
</span><span class="cx"> removeProxies = queryValues("rmProxy|")
</span><span class="cx">
</span><del>- # Update the auto-schedule value if specified.
- if autoSchedule is not None and (autoSchedule == "true" or
- autoSchedule == "false"):
</del><ins>+ # Update the auto-schedule-mode value if specified.
+ if autoScheduleMode:
</ins><span class="cx"> if (
</span><del>- principal.record.recordType != RecordType.user and
- principal.record.recordType != RecordType.group or
- principal.record.recordType == RecordType.user and
</del><ins>+ record.recordType != RecordType.user and
+ record.recordType != RecordType.group or
+ record.recordType == RecordType.user and
</ins><span class="cx"> config.Scheduling.Options.AutoSchedule.AllowUsers
</span><span class="cx"> ):
</span><del>- (yield principal.setAutoSchedule(autoSchedule == "true"))
- (yield principal.setAutoScheduleMode(autoScheduleMode))
</del><ins>+ autoScheduleMode = allowedAutoScheduleModes[autoScheduleMode]
+ yield record.setAutoScheduleMode(autoScheduleMode)
+ record.autoScheduleMode = autoScheduleMode
</ins><span class="cx">
</span><span class="cx"> # Update the proxies if specified.
</span><del>- for proxyId in removeProxies:
- proxy = yield self.getResourceById(request, proxyId)
- yield action_removeProxyPrincipal(
- self.root, self.directory, self.store,
- principal, proxy, proxyTypes=["read", "write"]
- )
</del><ins>+ if removeProxies:
+ yield action_removeProxy(self.store, record, *removeProxies)
</ins><span class="cx">
</span><del>- for proxyId in makeReadProxies:
- proxy = yield self.getResourceById(request, proxyId)
- yield action_addProxyPrincipal(
- self.root, self.directory, self.store,
- principal, "read", proxy
- )
</del><ins>+ if makeReadProxies:
+ yield action_addProxy(self.store, record, "read", *makeReadProxies)
</ins><span class="cx">
</span><del>- for proxyId in makeWriteProxies:
- proxy = yield self.getResourceById(request, proxyId)
- yield action_addProxyPrincipal(
- self.root, self.directory, self.store,
- principal, "write", proxy
- )
</del><ins>+ if makeWriteProxies:
+ yield action_addProxy(self.store, record, "write", *makeWriteProxies)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -700,8 +688,8 @@
</span><span class="cx"> """
</span><span class="cx"> resourceId = request.args.get('resourceId', [''])[0]
</span><span class="cx"> if resourceId:
</span><del>- principal = yield self.getResourceById(request, resourceId)
- yield self.resourceActions(request, principal)
</del><ins>+ record = yield recordForPrincipalID(self.directory, resourceId)
+ yield self.resourceActions(request, record)
</ins><span class="cx"> htmlContent = yield flattenString(request, WebAdminPage(self))
</span><span class="cx"> response = Response()
</span><span class="cx"> response.stream = MemoryStream(htmlContent)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavicalendardirectoryservicepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/icalendardirectoryservice.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/icalendardirectoryservice.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/caldav/icalendardirectoryservice.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -106,6 +106,15 @@
</span><span class="cx"> @rtype: C{bool}
</span><span class="cx"> """
</span><span class="cx">
</span><ins>+ def setAutoScheduleMode(autoScheduleMode): #@NoSelf
+ """
+ Sets the mode of automatic scheduling used for this record.
+
+ @param autoScheduleMode: the new mode
+ @type autoScheduleMode: L{AutoScheduleMode}
+ """
+
+
</ins><span class="cx"> def isProxyFor(other): #@NoSelf
</span><span class="cx"> """
</span><span class="cx"> Test whether the record is a calendar user proxy for the specified record.
</span></span></pre></div>
<a id="CalendarServertrunktxdavdpsclientpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/dps/client.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/dps/client.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/dps/client.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -44,7 +44,8 @@
</span><span class="cx"> WikiAccessForUIDCommand, ContinuationCommand,
</span><span class="cx"> StatsCommand, ExternalDelegatesCommand, ExpandedMemberUIDsCommand,
</span><span class="cx"> AddMembersCommand, RemoveMembersCommand,
</span><del>- UpdateRecordsCommand, ExpandedMembersCommand, FlushCommand
</del><ins>+ UpdateRecordsCommand, ExpandedMembersCommand, FlushCommand,
+ SetAutoScheduleModeCommand
</ins><span class="cx"> )
</span><span class="cx"> from txdav.who.delegates import RecordType as DelegatesRecordType
</span><span class="cx"> from txdav.who.directory import (
</span><span class="lines">@@ -422,6 +423,14 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><ins>+ def setAutoScheduleMode(self, record, autoScheduleMode):
+ return self._sendCommand(
+ SetAutoScheduleModeCommand,
+ uid=record.uid.encode("utf-8"),
+ autoScheduleMode=autoScheduleMode.name,
+ )
+
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def flush(self):
</span><span class="cx"> try:
</span></span></pre></div>
<a id="CalendarServertrunktxdavdpscommandspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/dps/commands.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/dps/commands.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/dps/commands.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -265,7 +265,16 @@
</span><span class="cx"> ]
</span><span class="cx">
</span><span class="cx">
</span><ins>+class SetAutoScheduleModeCommand(amp.Command):
+ arguments = [
+ ('uid', amp.String()),
+ ('autoScheduleMode', amp.String()),
+ ]
+ response = [
+ ('success', amp.Boolean()),
+ ]
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> class FlushCommand(amp.Command):
</span><span class="cx"> arguments = []
</span><span class="cx"> response = [
</span></span></pre></div>
<a id="CalendarServertrunktxdavdpsserverpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/dps/server.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/dps/server.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/dps/server.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -45,8 +45,10 @@
</span><span class="cx"> WikiAccessForUIDCommand, ContinuationCommand,
</span><span class="cx"> ExternalDelegatesCommand, StatsCommand, ExpandedMemberUIDsCommand,
</span><span class="cx"> AddMembersCommand, RemoveMembersCommand,
</span><del>- UpdateRecordsCommand, FlushCommand, # RemoveRecordsCommand,
</del><ins>+ UpdateRecordsCommand, FlushCommand, SetAutoScheduleModeCommand,
+ # RemoveRecordsCommand,
</ins><span class="cx"> )
</span><ins>+from txdav.who.idirectory import AutoScheduleMode
</ins><span class="cx"> from txdav.who.wiki import WikiAccessLevel
</span><span class="cx">
</span><span class="cx"> from zope.interface import implementer
</span><span class="lines">@@ -540,6 +542,21 @@
</span><span class="cx"> returnValue(response)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @SetAutoScheduleModeCommand.responder
+ @inlineCallbacks
+ def setAutoScheduleMode(self, uid, autoScheduleMode):
+ uid = uid.decode("utf-8")
+ record = yield self._directory.recordWithUID(uid)
+ autoScheduleMode = autoScheduleMode.decode("utf-8")
+ autoScheduleMode = AutoScheduleMode.lookupByName(autoScheduleMode)
+ yield self._directory.setAutoScheduleMode(record, autoScheduleMode)
+ response = {
+ "success": True
+ }
+ returnValue(response)
+
+
+
</ins><span class="cx"> @GroupsCommand.responder
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def groups(self, uid):
</span></span></pre></div>
<a id="CalendarServertrunktxdavdpstesttest_clientpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/dps/test/test_client.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/dps/test/test_client.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/dps/test/test_client.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> from txdav.who.test.support import (
</span><span class="cx"> TestRecord, CalendarInMemoryDirectoryService
</span><span class="cx"> )
</span><ins>+from txdav.who.idirectory import AutoScheduleMode
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> testMode = "xml" # "xml" or "od"
</span><span class="lines">@@ -442,6 +443,22 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><ins>+ def test_setAutoScheduleMode(self):
+ """
+ Verify setAutoSchedule works across DPS
+ """
+ record = yield self.client.recordWithUID(u"75EA36BE-F71B-40F9-81F9-CF59BF40CA8F")
+ # Defaults to automatic
+ self.assertEquals(record.autoScheduleMode, AutoScheduleMode.acceptIfFreeDeclineIfBusy)
+ # Change it to accept-if-busy
+ yield record.setAutoScheduleMode(AutoScheduleMode.acceptIfFree)
+ # Refetch it
+ record = yield self.client.recordWithUID(u"75EA36BE-F71B-40F9-81F9-CF59BF40CA8F")
+ # Verify it's changed
+ self.assertEquals(record.autoScheduleMode, AutoScheduleMode.acceptIfFree)
+
+
+ @inlineCallbacks
</ins><span class="cx"> def test_uid(self):
</span><span class="cx"> record = (yield self.client.recordWithUID(self.wsanchezUID))
</span><span class="cx"> self.assertTrue(u"wsanchez" in record.shortNames)
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhoaugmentpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/augment.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/augment.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/who/augment.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -471,7 +471,27 @@
</span><span class="cx"> returnValue(augmentedRecord)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def setAutoScheduleMode(self, record, autoScheduleMode):
+ augmentRecord = yield self._augmentDB.getAugmentRecord(
+ record.uid,
+ self.recordTypeToOldName(record.recordType)
+ )
+ if augmentRecord is not None:
+ autoScheduleMode = {
+ AutoScheduleMode.none: "none",
+ AutoScheduleMode.accept: "accept-always",
+ AutoScheduleMode.decline: "decline-always",
+ AutoScheduleMode.acceptIfFree: "accept-if-free",
+ AutoScheduleMode.declineIfBusy: "decline-if-busy",
+ AutoScheduleMode.acceptIfFreeDeclineIfBusy: "automatic",
+ }.get(autoScheduleMode)
</ins><span class="cx">
</span><ins>+ augmentRecord.autoScheduleMode = autoScheduleMode
+ yield self._augmentDB.addAugmentRecords([augmentRecord])
+
+
+
</ins><span class="cx"> class AugmentedDirectoryRecord(DirectoryRecord, CalendarDirectoryRecordMixin):
</span><span class="cx"> """
</span><span class="cx"> Augmented directory record.
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/directory.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/directory.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/who/directory.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -607,6 +607,10 @@
</span><span class="cx"> returnValue(autoScheduleMode)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ def setAutoScheduleMode(self, autoScheduleMode):
+ return self.service.setAutoScheduleMode(self, autoScheduleMode)
+
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def autoAcceptFromOrganizer(self, organizer):
</span><span class="cx"> try:
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_directorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_directory.py (15754 => 15755)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_directory.py        2016-07-07 18:53:32 UTC (rev 15754)
+++ CalendarServer/trunk/txdav/who/test/test_directory.py        2016-07-07 20:38:32 UTC (rev 15755)
</span><span class="lines">@@ -358,7 +358,22 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def test_setAutoScheduleMode(self):
+ """
+ Verify the record.setAutoScheduleMode( ) method
+ """
+ orion = yield self.directory.recordWithUID(u"orion")
+ # Defaults to automatic
+ self.assertEquals(orion.autoScheduleMode, AutoScheduleMode.acceptIfFreeDeclineIfBusy)
+ # Change it to decline-if-busy
+ yield orion.setAutoScheduleMode(AutoScheduleMode.declineIfBusy)
+ # Refetch it
+ orion = yield self.directory.recordWithUID(u"orion")
+ # Verify it's changed
+ self.assertEquals(orion.autoScheduleMode, AutoScheduleMode.declineIfBusy)
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> class DirectoryTestCaseFakeEmail(StoreTestCase):
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>