[CalendarServer-changes] [12993] CalendarServer/branches/users/sagen/move2who-4
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 25 09:55:29 PDT 2014
Revision: 12993
http://trac.calendarserver.org//changeset/12993
Author: sagen at apple.com
Date: 2014-03-25 09:55:29 -0700 (Tue, 25 Mar 2014)
Log Message:
-----------
It passes. test_principal.py. It passes.
Modified Paths:
--------------
CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/gateway.py
CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py
CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/test_principal.py
CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py
CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/test/util.py
CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/processing.py
CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/test/util.py
CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py
Modified: CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/gateway.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/gateway.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/gateway.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -383,92 +383,12 @@
command_getAddressAttributes = command_getLocationAttributes
-
-
-
- # @inlineCallbacks
- # def _setAttributes(self, )
- # # Set autoSchedule prior to the updateRecord so that the right
- # # value ends up in memcached
- # principal = principalForPrincipalID(command['GeneratedUID'],
- # directory=self.dir)
- # (yield principal.setAutoSchedule(command.get('AutoSchedule', False)))
- # (yield principal.setAutoAcceptGroup(command.get('AutoAcceptGroup', "")))
-
- # kwargs = {}
- # for key, info in attrMap.iteritems():
- # if key in command:
- # kwargs[info['attr']] = command[key]
- # try:
- # record = (yield updateRecord(False, self.dir, "locations", **kwargs))
- # except DirectoryError, e:
- # self.respondWithError(str(e))
- # return
-
- # readProxies = command.get("ReadProxies", None)
- # writeProxies = command.get("WriteProxies", None)
- # principal = principalForPrincipalID(record.guid, directory=self.dir)
- # (yield setProxies(self.store, principal, readProxies, writeProxies, directory=self.dir))
-
- # yield self.command_getLocationAttributes(command)
-
-
-
# Resources
def command_getResourceList(self, command):
self.respondWithRecordsOfTypes(self.dir, command, ["resources"])
- # @inlineCallbacks
- # def command_createResource(self, command):
- # kwargs = {}
- # for key, info in attrMap.iteritems():
- # if key in command:
- # kwargs[info['attr']] = command[key]
-
- # try:
- # record = (yield updateRecord(True, self.dir, "resources", **kwargs))
- # except DirectoryError, e:
- # self.respondWithError(str(e))
- # return
-
- # readProxies = command.get("ReadProxies", None)
- # writeProxies = command.get("WriteProxies", None)
- # principal = principalForPrincipalID(record.guid, directory=self.dir)
- # (yield setProxies(self.store, principal, readProxies, writeProxies, directory=self.dir))
-
- # self.respondWithRecordsOfTypes(self.dir, command, ["resources"])
-
-
- # @inlineCallbacks
- # def command_setResourceAttributes(self, command):
-
- # # Set autoSchedule prior to the updateRecord so that the right
- # # value ends up in memcached
- # principal = principalForPrincipalID(command['GeneratedUID'],
- # directory=self.dir)
- # (yield principal.setAutoSchedule(command.get('AutoSchedule', False)))
- # (yield principal.setAutoAcceptGroup(command.get('AutoAcceptGroup', "")))
-
- # kwargs = {}
- # for key, info in attrMap.iteritems():
- # if key in command:
- # kwargs[info['attr']] = command[key]
- # try:
- # record = (yield updateRecord(False, self.dir, "resources", **kwargs))
- # except DirectoryError, e:
- # self.respondWithError(str(e))
- # return
-
- # readProxies = command.get("ReadProxies", None)
- # writeProxies = command.get("WriteProxies", None)
- # principal = principalForPrincipalID(record.guid, directory=self.dir)
- # (yield setProxies(self.store, principal, readProxies, writeProxies, directory=self.dir))
-
- # yield self.command_getResourceAttributes(command)
-
-
# deferred
def command_getLocationAndResourceList(self, command):
return self.respondWithRecordsOfTypes(self.dir, command, ["locations", "resources"])
@@ -480,40 +400,6 @@
return self.respondWithRecordsOfTypes(self.dir, command, ["addresses"])
- # @inlineCallbacks
- # def command_createAddress(self, command):
- # kwargs = {}
- # for key, info in attrMap.iteritems():
- # if key in command:
- # kwargs[info['attr']] = command[key]
-
- # try:
- # yield updateRecord(True, self.dir, "addresses", **kwargs)
- # except DirectoryError, e:
- # self.respondWithError(str(e))
- # return
-
- # self.respondWithRecordsOfTypes(self.dir, command, ["addresses"])
-
-
-
-
- # @inlineCallbacks
- # def command_setAddressAttributes(self, command):
- # kwargs = {}
- # for key, info in attrMap.iteritems():
- # if key in command:
- # kwargs[info['attr']] = command[key]
- # try:
- # yield updateRecord(False, self.dir, "addresses", **kwargs)
- # except DirectoryError, e:
- # self.respondWithError(str(e))
- # return
-
- # yield self.command_getAddressAttributes(command)
-
-
-
@inlineCallbacks
def _delete(self, typeName, command):
uid = command['GeneratedUID']
@@ -649,76 +535,6 @@
yield self.respondWithProxies(command, record, proxyType)
-
- # @inlineCallbacks
- # def command_removeWriteProxy(self, command):
- # principal = principalForPrincipalID(command['Principal'], directory=self.dir)
- # if principal is None:
- # self.respondWithError("Principal not found: %s" % (command['Principal'],))
- # return
- # proxy = principalForPrincipalID(command['Proxy'], directory=self.dir)
- # if proxy is None:
- # self.respondWithError("Proxy not found: %s" % (command['Proxy'],))
- # return
- # try:
- # (yield removeProxy(self.root, self.dir, self.store, principal, proxy, proxyTypes=("write",)))
- # except ProxyError, e:
- # self.respondWithError(str(e))
- # return
- # except ProxyWarning, e:
- # pass
- # (yield self.respondWithProxies(self.dir, command, principal, "write"))
-
-
- # @inlineCallbacks
- # def command_listReadProxies(self, command):
- # principal = principalForPrincipalID(command['Principal'], directory=self.dir)
- # if principal is None:
- # self.respondWithError("Principal not found: %s" % (command['Principal'],))
- # return
- # (yield self.respondWithProxies(self.dir, command, principal, "read"))
-
-
- # @inlineCallbacks
- # def command_addReadProxy(self, command):
- # principal = principalForPrincipalID(command['Principal'], directory=self.dir)
- # if principal is None:
- # self.respondWithError("Principal not found: %s" % (command['Principal'],))
- # return
- # proxy = principalForPrincipalID(command['Proxy'], directory=self.dir)
- # if proxy is None:
- # self.respondWithError("Proxy not found: %s" % (command['Proxy'],))
- # return
- # try:
- # (yield addProxy(self.root, self.dir, self.store, principal, "read", proxy))
- # except ProxyError, e:
- # self.respondWithError(str(e))
- # return
- # except ProxyWarning, e:
- # pass
- # (yield self.respondWithProxies(self.dir, command, principal, "read"))
-
-
- # @inlineCallbacks
- # def command_removeReadProxy(self, command):
- # principal = principalForPrincipalID(command['Principal'], directory=self.dir)
- # if principal is None:
- # self.respondWithError("Principal not found: %s" % (command['Principal'],))
- # return
- # proxy = principalForPrincipalID(command['Proxy'], directory=self.dir)
- # if proxy is None:
- # self.respondWithError("Proxy not found: %s" % (command['Proxy'],))
- # return
- # try:
- # (yield removeProxy(self.root, self.dir, self.store, principal, proxy, proxyTypes=("read",)))
- # except ProxyError, e:
- # self.respondWithError(str(e))
- # return
- # except ProxyWarning, e:
- # pass
- # (yield self.respondWithProxies(self.dir, command, principal, "read"))
-
-
@inlineCallbacks
def command_purgeOldEvents(self, command):
"""
Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -1161,6 +1161,7 @@
@param organizer: the CUA of the organizer trying to schedule this principal
@type organizer: C{str}
+ @return: C{Deferred} firing a C{bool}
"""
return self.record.canAutoSchedule(organizer)
@@ -1184,9 +1185,8 @@
@param organizer: the CUA of the organizer scheduling this principal
@type organizer: C{str}
- @return: auto schedule mode; one of: none, accept-always, decline-always,
- accept-if-free, decline-if-busy, automatic (see stdconfig.py)
- @rtype: C{str}
+ @return: auto schedule mode
+ @rtype: C{Deferred} firing L{AutoScheduleMode}
"""
return self.record.getAutoScheduleMode(organizer)
@@ -1222,7 +1222,7 @@
@type organizer: C{str}
@return: True if the autoAcceptGroup is assigned, and the organizer is a member
of that group. False otherwise.
- @rtype: C{bool}
+ @rtype: C{Deferred} firing C{bool}
"""
return self.record.autoAcceptFromOrganizer()
Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/test_principal.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/test_principal.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/test_principal.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -15,18 +15,15 @@
##
from __future__ import print_function
-import os
from urllib import quote
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.cred.credentials import UsernamePassword
-from txweb2.dav.fileop import rmdir
from txweb2.dav.resource import AccessDeniedError
from txweb2.http import HTTPError
from txweb2.test.test_server import SimpleRequest
-from txdav.common.datastore.file import CommonDataStore
from txdav.xml import element as davxml
from twistedcaldav import carddavxml
@@ -34,21 +31,16 @@
from twistedcaldav.caldavxml import caldav_namespace
from twistedcaldav.config import config
from twistedcaldav.customxml import calendarserver_namespace
-from twistedcaldav.directory.addressbook import (
- DirectoryAddressBookHomeProvisioningResource
-)
-from twistedcaldav.directory.calendar import (
- DirectoryCalendarHomeProvisioningResource
-)
from twistedcaldav.directory.principal import (
DirectoryCalendarPrincipalResource,
DirectoryPrincipalResource,
DirectoryPrincipalTypeProvisioningResource,
)
from twistedcaldav.test.util import StoreTestCase
+from txdav.who.idirectory import AutoScheduleMode, RecordType as CalRecordType
+from twext.who.idirectory import RecordType
-
class ProvisionedPrincipals(StoreTestCase):
"""
Directory service provisioned principals.
@@ -80,7 +72,7 @@
#print("\n -> %s" % (directory.__class__.__name__,))
provisioningResource = self.principalRootResource
- provisioningURL = "/" + self.directory.__class__.__name__ + "/"
+ provisioningURL = "/principals/"
self.assertEquals(
provisioningURL,
provisioningResource.principalCollectionURL()
@@ -93,11 +85,18 @@
)
recordTypes = set((yield provisioningResource.listChildren()))
- self.assertEquals(recordTypes, set(self.directory.recordTypes()))
+ self.assertEquals(
+ recordTypes,
+ set(
+ [
+ self.directory.recordTypeToOldName(rt) for rt in
+ self.directory.recordTypes()
+ ]
+ )
+ )
for recordType in recordTypes:
- #print(" -> %s" % (recordType,))
- typeResource = provisioningResource.getChild(recordType)
+ typeResource = yield provisioningResource.getChild(recordType)
self.failUnless(
isinstance(
typeResource,
@@ -123,7 +122,9 @@
# Handle records with mulitple shortNames
expected = []
for r in (
- yield self.directory.recordsWithRecordType(recordType)
+ yield self.directory.recordsWithRecordType(
+ self.directory.oldNameToRecordType(recordType)
+ )
):
if r.uid != "disabled":
expected.extend(r.shortNames)
@@ -137,7 +138,7 @@
)
# shortName may be non-ascii
- recordURL = typeURL + quote(shortName) + "/"
+ recordURL = typeURL + quote(shortName.encode("utf-8")) + "/"
self.assertIn(
recordURL,
(
@@ -298,7 +299,7 @@
self.failIf(principal is not None)
# Explicitly check the disabled record
- provisioningResource = self.principalRootResource
+ provisioningResource = yield self.actualRoot.getChild("principals")
self.failUnlessIdentical(
(
@@ -413,9 +414,9 @@
yield hasProperty(
(calendarserver_namespace, "calendar-proxy-write-for")
)
- yield hasProperty(
- (calendarserver_namespace, "auto-schedule")
- )
+ # yield hasProperty(
+ # (calendarserver_namespace, "auto-schedule")
+ # )
else:
yield doesNotHaveProperty(
(caldav_namespace, "calendar-home-set")
@@ -438,9 +439,9 @@
yield doesNotHaveProperty(
(calendarserver_namespace, "calendar-proxy-write-for")
)
- yield doesNotHaveProperty(
- (calendarserver_namespace, "auto-schedule")
- )
+ # yield doesNotHaveProperty(
+ # (calendarserver_namespace, "auto-schedule")
+ # )
if record.hasContacts:
yield hasProperty(carddavxml.AddressBookHomeSet.qname())
@@ -578,8 +579,7 @@
for (
provisioningResource, recordType, recordResource, record
) in (yield self._allRecords()):
- if True: # user.enabled:
- self.assertEquals(record.guid, recordResource.principalUID())
+ self.assertEquals(record.uid, recordResource.principalUID())
@inlineCallbacks
@@ -610,10 +610,21 @@
provisioningResource, recordType, recordResource, record
) in (yield self._allRecords()):
if record.hasCalendars:
- self.failUnless(
- recordResource.canonicalCalendarUserAddress()
- .startswith("urn:uuid:")
- )
+ if self.directory.fieldName.guid in record.fields:
+ self.failUnless(
+ recordResource.canonicalCalendarUserAddress()
+ .startswith("urn:uuid:")
+ )
+ elif self.directory.fieldName.emailAddresses in record.fields:
+ self.failUnless(
+ recordResource.canonicalCalendarUserAddress()
+ .startswith("mailto:")
+ )
+ else:
+ self.failUnless(
+ recordResource.canonicalCalendarUserAddress()
+ .startswith("/principals/__uids__/")
+ )
@inlineCallbacks
@@ -621,27 +632,7 @@
"""
DirectoryPrincipalResource.addressBookHomeURLs(),
"""
- # No addressbook home provisioner should result in no addressbook
- # homes.
- for (
- provisioningResource, recordType, recordResource, record
- ) in (yield self._allRecords()):
- if record.hasContacts:
- self.failIf(tuple(recordResource.addressBookHomeURLs()))
- path = os.path.join(self.docroot, self.directory.__class__.__name__)
-
- if os.path.exists(path):
- rmdir(path)
- os.mkdir(path)
-
- addressBookRootResource = DirectoryAddressBookHomeProvisioningResource(
- self.directory,
- "/addressbooks/",
- self.storeUnderTest()
- )
-
- # AddressBook home provisioners should result in addressBook homes.
for (
provisioningResource, recordType, recordResource, record
) in (yield self._allRecords()):
@@ -655,6 +646,7 @@
self.failIf(tuple(recordResource.addressBookHomeURLs()))
record.hasContacts = True
+ addressBookRootResource = yield self.actualRoot.getChild("addressbooks")
addressBookRootURL = addressBookRootResource.url()
for homeURL in homeURLs:
@@ -668,36 +660,36 @@
DirectoryPrincipalResource.scheduleInboxURL(),
DirectoryPrincipalResource.scheduleOutboxURL()
"""
- # No calendar home provisioner should result in no calendar homes.
- for (
- provisioningResource, recordType, recordResource, record
- ) in (yield self._allRecords()):
- if record.hasCalendars:
- self.failIf(tuple(recordResource.calendarHomeURLs()))
- self.failIf(recordResource.scheduleInboxURL())
- self.failIf(recordResource.scheduleOutboxURL())
+ # # No calendar home provisioner should result in no calendar homes.
+ # for (
+ # provisioningResource, recordType, recordResource, record
+ # ) in (yield self._allRecords()):
+ # if record.hasCalendars:
+ # self.failIf(tuple(recordResource.calendarHomeURLs()))
+ # self.failIf(recordResource.scheduleInboxURL())
+ # self.failIf(recordResource.scheduleOutboxURL())
- # Need to create a calendar home provisioner for each service.
- calendarRootResources = {}
+ # # Need to create a calendar home provisioner for each service.
+ # calendarRootResources = {}
- path = os.path.join(self.docroot, self.directory.__class__.__name__)
+ # path = os.path.join(self.docroot, self.directory.__class__.__name__)
- if os.path.exists(path):
- rmdir(path)
- os.mkdir(path)
+ # if os.path.exists(path):
+ # rmdir(path)
+ # os.mkdir(path)
- # Need a data store
- _newStore = CommonDataStore(path, None, None, True, False)
+ # # Need a data store
+ # _newStore = CommonDataStore(path, None, None, True, False)
- provisioningResource = DirectoryCalendarHomeProvisioningResource(
- self.directory,
- "/calendars/",
- _newStore
- )
+ # provisioningResource = DirectoryCalendarHomeProvisioningResource(
+ # self.directory,
+ # "/calendars/",
+ # _newStore
+ # )
- calendarRootResources[self.directory.__class__.__name__] = (
- provisioningResource
- )
+ # calendarRootResources[self.directory.__class__.__name__] = (
+ # provisioningResource
+ # )
# Calendar home provisioners should result in calendar homes.
for (
@@ -713,11 +705,8 @@
self.failIf(tuple(recordResource.calendarHomeURLs()))
record.hasCalendars = True
- calendarRootURL = (
- calendarRootResources[
- record.service.__class__.__name__
- ].url()
- )
+ calendarRootResource = yield self.rootResource.getChild("calendars")
+ calendarRootURL = calendarRootResource.url()
inboxURL = recordResource.scheduleInboxURL()
outboxURL = recordResource.scheduleOutboxURL()
@@ -748,26 +737,31 @@
DirectoryPrincipalResource.canAutoSchedule()
"""
- # Set all resources and locations to auto-schedule, plus one user
- for (
- provisioningResource, recordType, recordResource, record
- ) in (yield self._allRecords()):
- if record.hasCalendars:
- if (
- recordType in ("locations", "resources") or
- record.uid == "cdaboo"
- ):
- recordResource.record.autoSchedule = True
+ # This test used to set the autoschedule mode in a separate loop, but
+ # the records aren't cached, so I've moved this into the later loop
+ # # Set all resources and locations to auto-schedule, plus one user
+ # for (
+ # provisioningResource, recordType, recordResource, record
+ # ) in (yield self._allRecords()):
+ # if record.hasCalendars:
+ # print("before", record, record.recordType, record.uid)
+ # if (
+ # recordType in (CalRecordType.location, CalRecordType.resource) or
+ # record.uid == "5A985493-EE2C-4665-94CF-4DFEA3A89500"
+ # ):
+ # record.fields[record.service.fieldName.lookupByName("autoScheduleMode")] = AutoScheduleMode.acceptIfFreeDeclineIfBusy
+ # print("modifying", record, record.fields)
+
# Default state - resources and locations, enabled, others not
for (
provisioningResource, recordType, recordResource, record
) in (yield self._allRecords()):
if record.hasCalendars:
- if recordType in ("locations", "resources"):
- self.assertTrue(recordResource.canAutoSchedule())
+ if recordType in (CalRecordType.location, CalRecordType.resource):
+ self.assertTrue((yield recordResource.canAutoSchedule()))
else:
- self.assertFalse(recordResource.canAutoSchedule())
+ self.assertFalse((yield recordResource.canAutoSchedule()))
# Set config to allow users
self.patch(config.Scheduling.Options.AutoSchedule, "AllowUsers", True)
@@ -776,12 +770,14 @@
) in (yield self._allRecords()):
if record.hasCalendars:
if (
- recordType in ("locations", "resources") or
- record.uid == "cdaboo"
+ recordType in (CalRecordType.location, CalRecordType.resource) or
+ record.uid == "5A985493-EE2C-4665-94CF-4DFEA3A89500"
):
- self.assertTrue(recordResource.canAutoSchedule())
+ record.fields[record.service.fieldName.lookupByName("autoScheduleMode")] = AutoScheduleMode.acceptIfFreeDeclineIfBusy
+
+ self.assertTrue((yield recordResource.canAutoSchedule()))
else:
- self.assertFalse(recordResource.canAutoSchedule())
+ self.assertFalse((yield recordResource.canAutoSchedule()))
# Set config to disallow all
self.patch(config.Scheduling.Options.AutoSchedule, "Enabled", False)
@@ -789,7 +785,7 @@
provisioningResource, recordType, recordResource, record
) in (yield self._allRecords()):
if record.hasCalendars:
- self.assertFalse(recordResource.canAutoSchedule())
+ self.assertFalse((yield recordResource.canAutoSchedule()))
@inlineCallbacks
@@ -808,18 +804,22 @@
if record.uid == "apollo":
# No organizer
- self.assertFalse(recordResource.canAutoSchedule())
+ self.assertFalse((yield recordResource.canAutoSchedule()))
# Organizer in auto-accept group
self.assertTrue(
- recordResource.canAutoSchedule(
- organizer="mailto:wsanchez at example.com"
+ (
+ yield recordResource.canAutoSchedule(
+ organizer="mailto:wsanchez at example.com"
+ )
)
)
# Organizer not in auto-accept group
self.assertFalse(
- recordResource.canAutoSchedule(
- organizer="mailto:a at example.com"
+ (
+ yield recordResource.canAutoSchedule(
+ organizer="mailto:a at example.com"
+ )
)
)
@@ -883,34 +883,34 @@
expected = (
(
"DAV:", "displayname",
- "morgen", "fullName", "morgen"
+ "morgen", "fullNames", "morgen"
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-type",
- "INDIVIDUAL", "recordType", "users"
+ "INDIVIDUAL", "recordType", RecordType.user
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-type",
- "GROUP", "recordType", "groups"
+ "GROUP", "recordType", RecordType.group
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-type",
- "RESOURCE", "recordType", "resources"
+ "RESOURCE", "recordType", CalRecordType.resource
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-type",
- "ROOM", "recordType", "locations"
+ "ROOM", "recordType", CalRecordType.location
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-address-set",
"/principals/__uids__/AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA/",
- "guid", "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"
+ "uid", "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-address-set",
"http://example.com:8008/principals/__uids__/"
"AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA/",
- "guid", "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"
+ "uid", "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"
),
(
"urn:ietf:params:xml:ns:caldav", "calendar-user-address-set",
Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -1872,12 +1872,12 @@
*[element.HRef(principal.principalURL()) for principal in results]
))
- elif name == "auto-schedule" and self.calendarsEnabled():
- autoSchedule = self.getAutoSchedule()
- returnValue(customxml.AutoSchedule("true" if autoSchedule else "false"))
+ # elif name == "auto-schedule" and self.calendarsEnabled():
+ # autoSchedule = self.getAutoSchedule()
+ # returnValue(customxml.AutoSchedule("true" if autoSchedule else "false"))
elif name == "auto-schedule-mode" and self.calendarsEnabled():
- autoScheduleMode = self.getAutoScheduleMode()
+ autoScheduleMode = yield self.getAutoScheduleMode()
returnValue(customxml.AutoScheduleMode(autoScheduleMode.description if autoScheduleMode else "default"))
elif namespace == carddav_namespace and self.addressBooksEnabled():
Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/test/util.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/test/util.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -183,6 +183,8 @@
resources = FilePath(config.DataRoot).child("resources.xml")
resources.setContent(resourcesFile.getContent())
+ augments = FilePath(config.DataRoot).child("augments.xml")
+ augments.setContent(augmentsFile.getContent())
class TestCase(txweb2.dav.test.util.TestCase):
Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/processing.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/scheduling/processing.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -434,9 +434,9 @@
# Handle auto-reply behavior
organizer = normalizeCUAddr(self.message.getOrganizer())
- if self.recipient.principal.canAutoSchedule(organizer=organizer):
+ if (yield self.recipient.principal.canAutoSchedule(organizer=organizer)):
# auto schedule mode can depend on who the organizer is
- mode = self.recipient.principal.getAutoScheduleMode(organizer=organizer)
+ mode = yield self.recipient.principal.getAutoScheduleMode(organizer=organizer)
send_reply, store_inbox, partstat = (yield self.checkAttendeeAutoReply(new_calendar, mode))
# Only store inbox item when reply is not sent or always for users
@@ -467,9 +467,9 @@
# Handle auto-reply behavior
organizer = normalizeCUAddr(self.message.getOrganizer())
- if self.recipient.principal.canAutoSchedule(organizer=organizer) and not hasattr(self.txn, "doing_attendee_refresh"):
+ if (yield self.recipient.principal.canAutoSchedule(organizer=organizer)) and not hasattr(self.txn, "doing_attendee_refresh"):
# auto schedule mode can depend on who the organizer is
- mode = self.recipient.principal.getAutoScheduleMode(organizer=organizer)
+ mode = yield self.recipient.principal.getAutoScheduleMode(organizer=organizer)
send_reply, store_inbox, partstat = (yield self.checkAttendeeAutoReply(new_calendar, mode))
# Only store inbox item when reply is not sent or always for users
@@ -548,7 +548,7 @@
# inbox item on them even if auto-schedule is true so that they get a notification
# of the cancel.
organizer = normalizeCUAddr(self.message.getOrganizer())
- autoprocessed = self.recipient.principal.canAutoSchedule(organizer=organizer)
+ autoprocessed = yield self.recipient.principal.canAutoSchedule(organizer=organizer)
store_inbox = not autoprocessed or self.recipient.principal.getCUType() == "INDIVIDUAL"
# Check to see if this is a cancel of the entire event
Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/test/util.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/test/util.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -109,11 +109,11 @@
def canAutoSchedule(self, organizer):
- return False
+ return succeed(False)
def getAutoScheduleMode(self, organizer):
- return "automatic"
+ return succeed("automatic")
def isProxyFor(self, other):
Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py 2014-03-24 19:36:48 UTC (rev 12992)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py 2014-03-25 16:55:29 UTC (rev 12993)
@@ -27,7 +27,9 @@
from twext.who.idirectory import RecordType as BaseRecordType
from twisted.cred.credentials import UsernamePassword
from twisted.internet.defer import inlineCallbacks, returnValue
-from txdav.who.idirectory import RecordType as DAVRecordType
+from txdav.who.idirectory import (
+ RecordType as DAVRecordType, AutoScheduleMode
+)
from txweb2.auth.digest import DigestedCredentials
log = Logger()
@@ -249,9 +251,9 @@
except AttributeError:
# No guid
pass
- cuas.add("/principals/__uids__/{uid}/".format(uid=self.uid))
+ cuas.add(u"/principals/__uids__/{uid}/".format(uid=self.uid))
for shortName in self.shortNames:
- cuas.add("/principals/{rt}/{sn}/".format(
+ cuas.add(u"/principals/{rt}/{sn}/".format(
rt=self.service.recordTypeToOldName(self.recordType),
sn=shortName)
)
@@ -341,15 +343,17 @@
def enabledAsOrganizer(self):
- # MOVE2WHO FIXME TO LOOK AT CONFIG
+ # FIXME:
+ from twistedcaldav.config import config
+
if self.recordType == self.service.recordType.user:
return True
elif self.recordType == self.service.recordType.group:
- return False # config.Scheduling.Options.AllowGroupAsOrganizer
+ return config.Scheduling.Options.AllowGroupAsOrganizer
elif self.recordType == self.service.recordType.location:
- return False # config.Scheduling.Options.AllowLocationAsOrganizer
+ return config.Scheduling.Options.AllowLocationAsOrganizer
elif self.recordType == self.service.recordType.resource:
- return False # config.Scheduling.Options.AllowResourceAsOrganizer
+ return config.Scheduling.Options.AllowResourceAsOrganizer
else:
return False
@@ -363,18 +367,50 @@
return self.loginAllowed
- #MOVE2WHO
def calendarsEnabled(self):
- # In the old world, this *also* looked at config:
- # return config.EnableCalDAV and self.enabledForCalendaring
- return self.hasCalendars
+ # FIXME:
+ from twistedcaldav.config import config
+ return config.EnableCalDAV and self.hasCalendars
+
+
+ @inlineCallbacks
+ def canAutoSchedule(self, organizer=None):
+ # FIXME:
+ from twistedcaldav.config import config
+
+ if config.Scheduling.Options.AutoSchedule.Enabled:
+ if (
+ config.Scheduling.Options.AutoSchedule.Always or
+ self.autoScheduleMode not in (AutoScheduleMode.none, None) or # right???
+ (
+ yield self.autoAcceptFromOrganizer(organizer)
+ )
+ ):
+ if (
+ self.getCUType() != "INDIVIDUAL" or
+ config.Scheduling.Options.AutoSchedule.AllowUsers
+ ):
+ returnValue(True)
+ returnValue(False)
+
+
+ @inlineCallbacks
def getAutoScheduleMode(self, organizer):
- # MOVE2WHO Fix this to take organizer into account:
- return self.autoScheduleMode
+ autoScheduleMode = self.autoScheduleMode
+ if (yield self.autoAcceptFromOrganizer(organizer)):
+ autoScheduleMode = AutoScheduleMode.acceptIfFreeDeclineIfBusy
+ returnValue(autoScheduleMode)
- def canAutoSchedule(self, organizer=None):
- # MOVE2WHO Fix this:
- return True
+ @inlineCallbacks
+ def autoAcceptFromOrganizer(self, organizer):
+ if organizer is not None and self.autoAcceptGroup is not None:
+ service = self.service
+ organizerRecord = yield service.recordWithCalendarUserAddress(organizer)
+ if organizerRecord is not None:
+ autoAcceptGroup = yield service.recordWithUID(self.autoAcceptGroup)
+ if organizerRecord.uid in (yield autoAcceptGroup.members()):
+ returnValue(True)
+ returnValue(False)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140325/ce0ddf39/attachment-0001.html>
More information about the calendarserver-changes
mailing list