[CalendarServer-changes] [5734] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 14 18:50:13 PDT 2010
Revision: 5734
http://trac.macosforge.org/projects/calendarserver/changeset/5734
Author: cdaboo at apple.com
Date: 2010-06-14 18:50:10 -0700 (Mon, 14 Jun 2010)
Log Message:
-----------
Allow sharer to schedule in shared calendars. Sharees cannot schedule. Can now upgrade a calendar with events
to shared.
Modified Paths:
--------------
CalendarServer/trunk/conf/caldavd-test.plist
CalendarServer/trunk/conf/carddavd-test.plist
CalendarServer/trunk/twistedcaldav/method/delete_common.py
CalendarServer/trunk/twistedcaldav/method/put_common.py
CalendarServer/trunk/twistedcaldav/scheduling/utils.py
CalendarServer/trunk/twistedcaldav/sharing.py
CalendarServer/trunk/twistedcaldav/static.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/conf/caldavd-test.plist 2010-06-15 01:50:10 UTC (rev 5734)
@@ -686,8 +686,6 @@
<dict>
<key>Enabled</key>
<true/>
- <key>AllowScheduling</key>
- <false/>
</dict>
<key>AddressBooks</key>
<dict>
Modified: CalendarServer/trunk/conf/carddavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/carddavd-test.plist 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/conf/carddavd-test.plist 2010-06-15 01:50:10 UTC (rev 5734)
@@ -704,8 +704,6 @@
<dict>
<key>Enabled</key>
<false/>
- <key>AllowScheduling</key>
- <false/>
</dict>
<key>AddressBooks</key>
<dict>
Modified: CalendarServer/trunk/twistedcaldav/method/delete_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/delete_common.py 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/twistedcaldav/method/delete_common.py 2010-06-15 01:50:10 UTC (rev 5734)
@@ -33,6 +33,7 @@
from twistedcaldav.caldavxml import caldav_namespace, ScheduleTag
from twistedcaldav.config import config
+from twistedcaldav.customxml import calendarserver_namespace
from twistedcaldav.memcachelock import MemcacheLock, MemcacheLockTimeoutError
from twistedcaldav.method.report_common import applyToAddressBookCollections, applyToCalendarCollections
from twistedcaldav.resource import isCalendarCollectionResource,\
@@ -147,6 +148,14 @@
scheduler = ImplicitScheduler()
do_implicit_action, _ignore = (yield scheduler.testImplicitSchedulingDELETE(self.request, delresource, calendar))
if do_implicit_action:
+ # Cannot do implicit in sharee's shared calendar
+ isvirt = (yield parent.isVirtualShare(self.request))
+ if isvirt:
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (calendarserver_namespace, "sharee-privilege-needed",),
+ description="Sharee's cannot schedule"
+ ))
lock = MemcacheLock("ImplicitUIDLock", calendar.resourceUID(), timeout=60.0)
try:
Modified: CalendarServer/trunk/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put_common.py 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/twistedcaldav/method/put_common.py 2010-06-15 01:50:10 UTC (rev 5734)
@@ -780,6 +780,16 @@
))
if do_implicit_action and self.allowImplicitSchedule:
+
+ # Cannot do implicit in sharee's shared calendar
+ isvirt = (yield self.destinationparent.isVirtualShare(self.request))
+ if isvirt:
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (calendarserver_namespace, "sharee-privilege-needed",),
+ description="Sharee's cannot schedule"
+ ))
+
new_calendar = (yield scheduler.doImplicitScheduling(self.schedule_tag_match))
if new_calendar:
if isinstance(new_calendar, int):
Modified: CalendarServer/trunk/twistedcaldav/scheduling/utils.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/utils.py 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/twistedcaldav/scheduling/utils.py 2010-06-15 01:50:10 UTC (rev 5734)
@@ -14,12 +14,12 @@
# limitations under the License.
##
-from twisted.internet.defer import inlineCallbacks, succeed, returnValue
+from twisted.internet.defer import inlineCallbacks, returnValue
from twistedcaldav.method import report_common
from twext.web2.dav.util import joinURL
@inlineCallbacks
-def getCalendarObjectForPrincipals(request, principal, uid):
+def getCalendarObjectForPrincipals(request, principal, uid, allow_shared=False):
"""
Get a copy of the event for a principal.
"""
@@ -40,8 +40,13 @@
request._rememberResource(calendar_home, calendar_home.url())
# Run a UID query against the UID
+ @inlineCallbacks
+ def queryCalendarCollection(collection, uri):
+ if not allow_shared:
+ isvirt = (yield collection.isVirtualShare(request))
+ if isvirt:
+ returnValue(True)
- def queryCalendarCollection(collection, uri):
rname = collection.index().resourceNameForUID(uid)
if rname:
resource = collection.getChild(rname)
@@ -51,9 +56,9 @@
result["resource_name"] = rname
result["calendar_collection"] = collection
result["calendar_collection_uri"] = uri
- return succeed(False)
+ returnValue(False)
else:
- return succeed(True)
+ returnValue(True)
# NB We are by-passing privilege checking here. That should be OK as the data found is not
# exposed to the user.
Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/twistedcaldav/sharing.py 2010-06-15 01:50:10 UTC (rev 5734)
@@ -70,11 +70,6 @@
def upgradeToShare(self, request):
""" Upgrade this collection to a shared state """
- # For calendars we only allow upgrades is shared-scheduling is on
- if request.method not in ("MKCALENDAR", "MKCOL") and self.isCalendarCollection() and \
- not config.Sharing.Calendars.AllowScheduling and len(self.listChildren()) != 0:
- raise HTTPError(StatusResponse(responsecode.FORBIDDEN, "Cannot upgrade to shared calendar"))
-
# Change resourcetype
rtype = (yield self.resourceType(request))
rtype = davxml.ResourceType(*(rtype.children + (customxml.SharedOwner(),)))
@@ -614,8 +609,7 @@
def _autoShare(isShared, request):
if not isShared:
- if not self.isCalendarCollection() or config.Sharing.Calendars.AllowScheduling or len(self.listChildren()) == 0:
- return self.upgradeToShare(request)
+ return self.upgradeToShare(request)
else:
return succeed(True)
raise HTTPError(StatusResponse(responsecode.FORBIDDEN, "Cannot upgrade to shared calendar"))
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/twistedcaldav/static.py 2010-06-15 01:50:10 UTC (rev 5734)
@@ -56,9 +56,10 @@
from twext.web2.http import HTTPError, StatusResponse
from twext.web2.dav import davxml
from twext.web2.dav.element.base import dav_namespace
-from twext.web2.dav.fileop import mkcollection, rmdir, delete
+from twext.web2.dav.fileop import mkcollection, rmdir
from twext.web2.dav.http import ErrorResponse
from twext.web2.dav.idav import IDAVResource
+from twext.web2.dav.method import put_common, delete_common
from twext.web2.dav.noneprops import NonePropertyStore
from twext.web2.dav.resource import AccessDeniedError
from twext.web2.dav.resource import davPrivilegeSet
@@ -1409,19 +1410,27 @@
def _writeNotification(self, request, uid, rname, xmltype, xmldata):
- # TODO: use the generic StoreObject api so that quota, sync-token etc all get changed properly
child = self.createSimilarFile(self.fp.child(rname).path)
- child.fp.setContent(xmldata)
- child.writeDeadProperty(davxml.GETContentType.fromString(generateContentType(MimeType("text", "xml", params={"charset":"utf-8"}))))
- child.writeDeadProperty(customxml.NotificationType(xmltype))
-
- return succeed(True)
+ def _defer(_):
+ child.writeDeadProperty(davxml.GETContentType.fromString(generateContentType(MimeType("text", "xml", params={"charset":"utf-8"}))))
+ child.writeDeadProperty(customxml.NotificationType(xmltype))
+ return True
+
+ url = request.urlForResource(self)
+ url = joinURL(url, rname)
+ request._rememberResource(child, url)
+ d = put_common.storeResource(request, data=xmldata, destination=child, destination_uri=url)
+ d.addCallback(_defer)
+ return d
+
def _deleteNotification(self, request, rname):
- # TODO: use the generic DeleteResource api so that quota, sync-token etc all get changed properly
- childfp = self.fp.child(rname)
- return delete("", childfp)
+ child = self.createSimilarFile(self.fp.child(rname).path)
+ url = request.urlForResource(self)
+ url = joinURL(url, rname)
+ request._rememberResource(child, url)
+ return delete_common.deleteResource(request, child, url)
class NotificationFile(NotificationResource, CalDAVFile):
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2010-06-15 00:35:49 UTC (rev 5733)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2010-06-15 01:50:10 UTC (rev 5734)
@@ -338,7 +338,6 @@
"Calendars" : {
"Enabled" : True, # Calendar on/off switch
- "AllowScheduling" : False, # Scheduling in shared calendars
},
"AddressBooks" : {
"Enabled" : True, # Address Books on/off switch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100614/45d1e89f/attachment-0001.html>
More information about the calendarserver-changes
mailing list