<!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>[13754] CalendarServer/branches/users/gaya/groupsharee2/txdav</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/13754">13754</a></dd>
<dt>Author</dt> <dd>gaya@apple.com</dd>
<dt>Date</dt> <dd>2014-07-11 16:57:30 -0700 (Fri, 11 Jul 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>one more test working</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoresqlpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoretesttest_sql_sharingpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresqlpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py (13753 => 13754)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py        2014-07-11 20:46:58 UTC (rev 13753)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py        2014-07-11 23:57:30 UTC (rev 13754)
</span><span class="lines">@@ -1989,17 +1989,34 @@
</span><span class="cx"> @param shareeUID: UID of the sharee
</span><span class="cx"> @type shareeUID: C{str}
</span><span class="cx"> """
</span><del>- # Cancel invites - we'll just use whatever userid we are given
</del><span class="cx">
</span><ins>+ if not (
+ config.Sharing.Enabled and
+ config.Sharing.Calendars.Enabled and
+ config.Sharing.Calendars.Groups.Enabled
+ ):
+ returnValue(
+ (yield super(Calendar, self).uninviteUIDFromShare(shareeUID))
+ )
+
</ins><span class="cx"> record = yield self._txn.directoryService().recordWithUID(shareeUID.decode("utf-8"))
</span><span class="cx"> if (
</span><span class="cx"> record is None or
</span><del>- record.recordType != RecordType.group or not (
- config.Sharing.Enabled and
- config.Sharing.Calendars.Enabled and
- config.Sharing.Calendars.Groups.Enabled
</del><ins>+ record.recordType != RecordType.group
+ ):
+ # delete all group sharees and individual sharees
+ shareeView = yield self.shareeView(shareeUID)
+ if shareeView is None:
+ returnValue(None)
+
+ # delete all group links for view's home
+ gs = schema.GROUP_SHAREE
+ yield Delete(
+ From=gs,
+ Where=(gs.CALENDAR_HOME_ID == shareeView.viewerHome()._resourceID).And(
+ gs.CALENDAR_ID == self._resourceID)
</ins><span class="cx"> )
</span><del>- ):
</del><ins>+
</ins><span class="cx"> returnValue(
</span><span class="cx"> (yield super(Calendar, self).uninviteUIDFromShare(shareeUID))
</span><span class="cx"> )
</span><span class="lines">@@ -2020,7 +2037,6 @@
</span><span class="cx"> gs.GROUP_ID == groupID
</span><span class="cx"> )
</span><span class="cx"> )
</span><del>-
</del><span class="cx"> if newMode is None:
</span><span class="cx"> # only group was shared, do delete share
</span><span class="cx"> yield super(Calendar, self).uninviteUIDFromShare(memberUID)
</span><span class="lines">@@ -2029,7 +2045,6 @@
</span><span class="cx"> yield super(Calendar, self).inviteUIDToShare(memberUID, newMode)
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> icalfbtype_to_indexfbtype = {
</span><span class="cx"> "UNKNOWN" : 0,
</span><span class="cx"> "FREE" : 1,
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoretesttest_sql_sharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py (13753 => 13754)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py        2014-07-11 20:46:58 UTC (rev 13753)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py        2014-07-11 23:57:30 UTC (rev 13754)
</span><span class="lines">@@ -616,8 +616,8 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def _check_notifications(self, home, items):
- notifyHome = yield self.transactionUnderTest().notificationsWithUID(home)
</del><ins>+ def _check_notifications(self, uid, items):
+ notifyHome = yield self.transactionUnderTest().notificationsWithUID(uid)
</ins><span class="cx"> notifications = yield notifyHome.listNotificationObjects()
</span><span class="cx"> self.assertEqual(set(notifications), set(items))
</span><span class="cx">
</span><span class="lines">@@ -659,23 +659,12 @@
</span><span class="cx"> self.assertEqual((yield shareeViews[i].effectiveShareMode()), _BIND_MODE_READ)
</span><span class="cx"> self.assertEqual(invites[i].status, _BIND_STATUS_INVITED)
</span><span class="cx"> self.assertEqual(invites[i].summary, "summary")
</span><del>- #inviteUID = shareeView.shareUID()
</del><ins>+ yield self._check_notifications(invites[i].shareeUID, [invites[i].uid, ])
</ins><span class="cx">
</span><span class="cx"> self.assertTrue(calendar.isShared())
</span><span class="cx">
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><del>- '''
- sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
- self.assertTrue(sharedParent is None)
- #yield self._check_notifications("user02", [inviteUID, ])
-
- group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
- self.assertTrue(group.isShared())
-
- yield self.commit()
- '''
-
</del><span class="cx"> # Uninvite
</span><span class="cx"> calendar = yield self.calendarUnderTest(home="user01", name="calendar")
</span><span class="cx"> invites = yield calendar.sharingInvites()
</span><span class="lines">@@ -683,13 +672,12 @@
</span><span class="cx"> self.assertTrue(calendar.isShared())
</span><span class="cx">
</span><span class="cx"> yield calendar.uninviteUIDFromShare("group02")
</span><del>- invites = yield calendar.sharingInvites()
- self.assertEqual(len(invites), 0)
</del><ins>+ uninvites = yield calendar.sharingInvites()
+ self.assertEqual(len(uninvites), 0)
</ins><span class="cx"> self.assertTrue(calendar.isShared())
</span><span class="cx">
</span><del>- yield self._check_notifications("user06", [])
- yield self._check_notifications("user07", [])
- yield self._check_notifications("user08", [])
</del><ins>+ for i in range(3):
+ yield self._check_notifications(invites[i].shareeUID, [])
</ins><span class="cx">
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="lines">@@ -706,48 +694,54 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # Invite
</span><del>- group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
- invites = yield group.sharingInvites()
</del><ins>+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
</ins><span class="cx"> self.assertEqual(len(invites), 0)
</span><del>- self.assertFalse(group.isShared())
</del><ins>+ self.assertFalse(calendar.isShared())
</ins><span class="cx">
</span><del>- shareeView = yield group.inviteUIDToShare("user02", _BIND_MODE_READ, "summary")
- invites = yield group.sharingInvites()
- self.assertEqual(len(invites), 1)
- inviteUID = shareeView.shareUID()
</del><ins>+ shareeViews = yield calendar.inviteUIDToShare("group02", _BIND_MODE_READ, "summary")
+ self.assertEqual(len(shareeViews), 3)
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 3)
+ shareeViews = sorted(shareeViews, key=lambda shareeView: shareeView.viewerHome().uid())
+ invites = sorted(invites, key=lambda invitee: invitee.shareeUID)
+ for i in range(3):
+ self.assertEqual(invites[i].uid, shareeViews[i].shareUID())
+ self.assertEqual(invites[i].ownerUID, "user01")
+ self.assertEqual(invites[i].shareeUID, shareeViews[i].viewerHome().uid())
+ self.assertEqual(invites[i].mode, _BIND_MODE_GROUP)
+ self.assertEqual((yield shareeViews[i].effectiveShareMode()), _BIND_MODE_READ)
+ self.assertEqual(invites[i].status, _BIND_STATUS_INVITED)
+ self.assertEqual(invites[i].summary, "summary")
+ yield self._check_notifications(invites[i].shareeUID, [invites[i].uid, ])
</ins><span class="cx">
</span><del>- sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
- self.assertTrue(sharedParent is None)
</del><ins>+ self.assertTrue(calendar.isShared())
</ins><span class="cx">
</span><del>- yield self._check_notifications("user02", [inviteUID, ])
-
- self.assertTrue(group.isShared())
-
</del><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Accept
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
- yield shareeHome.acceptShare(inviteUID)
</del><ins>+ for invite in invites:
+ shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+ yield shareeHome.acceptShare(invite.uid)
</ins><span class="cx">
</span><del>- yield self._check_calendar("user02", "user01", self.group1_children)
- yield self._check_notifications("user01", [inviteUID + "-reply", ])
</del><ins>+ yield self._check_notifications("user01", [invite.uid + "-reply" for invite in invites])
</ins><span class="cx">
</span><del>- group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
- self.assertTrue(group.isShared())
</del><ins>+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ self.assertTrue(calendar.isShared())
</ins><span class="cx">
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Re-accept
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
- yield shareeHome.acceptShare(inviteUID)
</del><ins>+ for invite in invites:
+ shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+ yield shareeHome.acceptShare(invite.uid)
</ins><span class="cx">
</span><del>- yield self._check_calendar("user02", "user01", self.group1_children)
- yield self._check_notifications("user01", [inviteUID + "-reply", ])
</del><ins>+ yield self._check_notifications("user01", [invite.uid + "-reply" for invite in invites])
</ins><span class="cx">
</span><del>- group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
- self.assertTrue(group.isShared())
</del><ins>+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ self.assertTrue(calendar.isShared())
</ins><span class="cx">
</span><del>-
</del><ins>+ '''
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_decline_share(self):
</span><span class="cx"> """
</span><span class="lines">@@ -775,7 +769,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Decline
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID)
</span><span class="cx">
</span><span class="cx"> sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
</span><span class="lines">@@ -789,7 +783,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Re-decline
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID)
</span><span class="cx">
</span><span class="cx"> sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
</span><span class="lines">@@ -829,7 +823,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Accept
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.acceptShare(inviteUID)
</span><span class="cx">
</span><span class="cx"> yield self._check_calendar("user02", "user01", self.group1_children)
</span><span class="lines">@@ -841,7 +835,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Decline
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID)
</span><span class="cx">
</span><span class="cx"> sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
</span><span class="lines">@@ -851,8 +845,8 @@
</span><span class="cx">
</span><span class="cx"> group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
</span><span class="cx"> self.assertTrue(group.isShared())
</span><ins>+ '''
</ins><span class="cx">
</span><del>-
</del><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_accept_remove_share(self):
</span><span class="cx"> """
</span><span class="lines">@@ -878,7 +872,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Accept
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.acceptShare(inviteUID)
</span><span class="cx">
</span><span class="cx"> yield self._check_calendar("user02", "user01", self.group1_children)
</span><span class="lines">@@ -966,7 +960,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Decline one
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID1)
</span><span class="cx">
</span><span class="cx"> yield self._check_calendar("user02", "user01", self.group2_children)
</span><span class="lines">@@ -979,7 +973,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Decline other
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID2)
</span><span class="cx">
</span><span class="cx"> sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
</span><span class="lines">@@ -1006,7 +1000,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Decline one
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID2)
</span><span class="cx">
</span><span class="cx"> yield self._check_calendar("user02", "user01", self.group1_children)
</span><span class="lines">@@ -1021,7 +1015,7 @@
</span><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Decline other
</span><del>- shareeHome = yield self.calendarHomeUnderTest(name="user02")
</del><ins>+ shareeHome = yield self.homeUnderTest(name="user02")
</ins><span class="cx"> yield shareeHome.declineShare(inviteUID1)
</span><span class="cx">
</span><span class="cx"> sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py (13753 => 13754)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py        2014-07-11 20:46:58 UTC (rev 13753)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py        2014-07-11 23:57:30 UTC (rev 13754)
</span><span class="lines">@@ -4731,7 +4731,6 @@
</span><span class="cx"> """
</span><span class="cx"> Called on the owner's resource.
</span><span class="cx"> """
</span><del>-
</del><span class="cx"> # When deleting the message is the sharee's display name
</span><span class="cx"> displayname = shareeView.shareMessage()
</span><span class="cx"> if notificationState == _BIND_STATUS_DELETED:
</span></span></pre>
</div>
</div>
</body>
</html>