[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/ - added sharing view

Yvo Schubbe cvs-admin at zope.org
Mon May 13 11:21:52 UTC 2013


Log message for revision 130238:
  - added sharing view

Changed:
  U   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/TODO.rst
  U   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml
  U   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder.py
  A   Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder_sharing.pt
  U   Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/CMF_BTree_Folder.xml
  U   Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/Folder.xml

-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/TODO.rst
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/TODO.rst	2013-05-13 07:30:14 UTC (rev 130237)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/TODO.rst	2013-05-13 11:21:52 UTC (rev 130238)
@@ -49,10 +49,10 @@
 - [x] folder_rename_control.py -> ContentsView.handle_rename_success
 - [x] folder_rename_template.pt -> folder_rename.pt
 
-[ ] IFolderish @@sharing.html:
+[x] IFolderish @@sharing.html:
 ------------------------------
-- [ ] folder_localrole_form.pt
-- [ ] folder_localrole_edit.py
+- [x] folder_localrole_edit.py -> FolderSharingView
+- [x] folder_localrole_form.pt -> folder_sharing.pt
 
 [x] IMutableMinimalDublinCore @@properties.html:
 ------------------------------------------------

Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml	2013-05-13 07:30:14 UTC (rev 130237)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/configure.zcml	2013-05-13 11:21:52 UTC (rev 130238)
@@ -26,6 +26,15 @@
       />
 
   <browser:page
+      for="Products.CMFCore.interfaces.IFolderish"
+      layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
+      name="sharing.html"
+      class=".folder.FolderSharingView"
+      template="folder_sharing.pt"
+      permission="cmf.ChangeLocalRoles"
+      />
+
+  <browser:page
       for="Products.CMFCore.interfaces.ISyndicatable"
       layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
       name="rss.xml"

Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder.py	2013-05-13 07:30:14 UTC (rev 130237)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder.py	2013-05-13 11:21:52 UTC (rev 130238)
@@ -549,3 +549,54 @@
     @memoize
     def has_local(self):
         return 'local_pt' in self.context.objectIds()
+
+
+class FolderSharingView(EditFormBase):
+
+    """Set local roles.
+    """
+
+    def __call__(self, ADD=None, DELETE=None):
+        if ADD:
+            self.mtool.setLocalRoles(
+                obj=self.context,
+                member_ids=self.request.get('member_ids', ()),
+                member_role=self.request.get('member_role', ''),
+                REQUEST=self.request)
+        elif DELETE:
+            self.mtool.deleteLocalRoles(
+                obj=self.context,
+                member_ids=self.request.get('member_ids', ()),
+                REQUEST=self.request)
+        else:
+            return self.index()
+        self.status = _(u'Local Roles changed.')
+        return self._setRedirect('portal_types', 'object/localroles')
+
+    @property
+    @memoize
+    def mtool(self):
+        return getUtility(IMembershipTool)
+
+    @property
+    def searching(self):
+        return self.request.get('role_submit', None)
+
+    def found(self):
+        search_param = self.request.get('search_param', '')
+        search_term = self.request.get('search_term', '')
+        return self.mtool.searchMembers(search_param=search_param,
+                                        search_term=search_term)
+
+    @property
+    def roles(self):
+        return self.mtool.getCandidateLocalRoles(self.context)
+
+    @property
+    def lroles(self):
+        return self.context.get_local_roles()
+
+    @property
+    @memoize
+    def auth_name(self):
+        return self.mtool.getAuthenticatedMember().getId()

Added: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder_sharing.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder_sharing.pt	                        (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder_sharing.pt	2013-05-13 11:21:52 UTC (rev 130238)
@@ -0,0 +1,187 @@
+<html metal:use-macro="context/@@standard_macros/page">
+<body>
+
+<metal:slot metal:fill-slot="body" i18n:domain="cmf_default">
+<tal:case tal:condition="not: view/searching">
+<!-- Search -->
+
+<h2 i18n:translate="">Assign local roles: Search Members</h2>
+
+<form method="post" action="folder_localrole_form"
+      tal:attributes="action request/ACTUAL_URL"
+>
+
+<table class="FormLayout">
+ <tr>
+  <th i18n:translate="">Search by</th>
+  <td>
+    <select name="search_param">
+      <option value="username" i18n:translate="">User Name</option>
+      <option value="email" i18n:translate="">Email Address</option>
+    </select>
+  </td>
+ </tr>
+ <tr>
+   <th i18n:translate="">Search Term</th>
+   <td><input type="text" name="search_term" size="30" /></td>
+ </tr>
+ <tr>
+   <td><br /></td>
+   <td>
+    <input type="submit" name="role_submit" value="Search"
+           i18n:attributes="value" />
+   </td>
+ </tr>
+</table>
+
+</form>
+
+
+<!-- End search -->
+</tal:case>
+
+<tal:case tal:condition="view/searching">
+<!-- Assignment -->
+
+<h2 i18n:translate="">Assign local roles: Search Results</h2>
+
+<tal:case tal:condition="view/found">
+
+ <p i18n:translate="">Select Member(s) and a role to assign:</p>
+
+ <form method="post" action="folder_localrole_edit"
+       tal:attributes="action request/ACTUAL_URL"
+ >
+  <input type="hidden" name="ADD" value="add" />
+
+  <table class="FormLayout">
+
+   <tr>
+    <td width="16"><br /></td>
+    <th style="text-align:left;" i18n:translate="">User</th>
+    <th style="text-align:left;" i18n:translate="">Email address</th>
+   </tr>
+
+   <tr tal:repeat="member view/found">
+    <td width="16">
+     <input type="checkbox" name="member_ids:list"
+            value=""
+            tal:attributes="value member/username" />
+    </td>
+    <td tal:content="member/username"> Username 1 </td>
+    <td tal:content="member/email"> Email 1 </td>
+   </tr>
+
+   <tr tal:condition="nothing">
+    <td width="16">
+     <input type="checkbox" name="member_ids:list" value="" />
+    </td>
+    <td> Username 2 </td>
+    <td> Email 2 </td>
+   </tr>
+
+   <tr>
+    <td colspan="3"><br /></td>
+   </tr>
+
+   <tr>
+    <th colspan="2" i18n:translate="">Role to assign:</th>
+    <td>
+     <select name="member_role">
+      <option tal:repeat="role view/roles"
+              tal:content="role"> Role1 </option>
+      <option tal:condition="nothing"> Role2 </option>
+      <option tal:condition="nothing"> Role3 </option>
+     </select>
+    </td>
+   </tr>
+
+   <tr>
+    <td colspan="3"><br /></td>
+   </tr>
+
+   <tr>
+    <td width="16"><br /></td>
+    <td colspan="2">
+     <input type="submit" value="Assign Roles" i18n:attributes="value" />
+    </td>
+   </tr>
+
+  </table>
+ </form>
+</tal:case>
+
+<tal:case tal:condition="not: view/found">
+ <p i18n:translate="">Sorry, no members matched your search.</p>
+</tal:case>
+
+<!-- End assignment -->
+</tal:case>
+
+<hr />
+
+<h2 i18n:translate="">Currently assigned local roles</h2>
+
+<p i18n:translate="">These users currently have local roles assigned in this
+  folder:</p>
+
+<form method="post" action="folder_localrole_edit"
+      tal:attributes="action request/ACTUAL_URL"
+>
+ <input type="hidden" name="DELETE" value="delete" />
+ <input type="hidden" name="member_role" value="" />
+
+ <table class="FormLayout">
+ <tr>
+   <td width="16"><br /></td>
+   <th style="text-align:left;" i18n:translate="">User</th>
+   <th style="text-align:left;" i18n:translate="">Role(s)</th>
+ </tr>
+
+ <tr tal:repeat="role_tuple view/lroles">
+  <td width="16" tal:define="user_name python: role_tuple[0]">
+   <input type="checkbox" name="member_ids:list"
+          value="id"
+          tal:attributes="value user_name"
+          tal:condition="python: user_name != view.auth_name" />
+   <br tal:condition="python: user_name == view.auth_name" />
+  </td>
+  <td tal:content="python: role_tuple[0]">Username 1</td>
+  <td tal:content="python: ', '.join(role_tuple[1])">
+   Role1, Role2
+  </td>
+ </tr>
+
+ <tr tal:condition="nothing">
+  <td width="16">
+   <input type="checkbox" name="member_ids:list" value="id" />
+  </td>
+  <td> Username 2 </td>
+  <td> Role3 </td>
+ </tr>
+
+ <tr tal:condition="nothing">
+  <td width="16">
+   <br />
+  </td>
+  <td> Auth username </td>
+  <td> Role1, Role2, Role3 </td>
+ </tr>
+
+ <tr>
+  <td colspan="3"><br /></td>
+ </tr>
+
+ <tr>
+   <td><br /></td>
+   <td colspan="2">
+    <input type="submit" value="Delete" i18n:attributes="value" />
+   </td>
+ </tr>
+
+</table>
+</form>
+</metal:slot>
+
+</body>
+</html>


Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/browser/content/folder_sharing.pt
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/CMF_BTree_Folder.xml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/CMF_BTree_Folder.xml	2013-05-13 07:30:14 UTC (rev 130237)
+++ Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/CMF_BTree_Folder.xml	2013-05-13 11:21:52 UTC (rev 130238)
@@ -3,6 +3,7 @@
  <alias from="(Default)" to="@@view.html"/>
  <alias from="folder_contents" to="@@edit.html"/>
  <alias from="folder_edit_form" to="@@properties.html"/>
+ <alias from="folder_localrole_form" to="@@sharing.html"/>
  <alias from="index.html" to="@@view.html"/>
  <alias from="view" to="@@view.html"/>
 </object>

Modified: Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/Folder.xml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/Folder.xml	2013-05-13 07:30:14 UTC (rev 130237)
+++ Products.CMFDefault/trunk/Products/CMFDefault/profiles/views_support/types/Folder.xml	2013-05-13 11:21:52 UTC (rev 130238)
@@ -3,6 +3,7 @@
  <alias from="(Default)" to="@@view.html"/>
  <alias from="folder_contents" to="@@edit.html"/>
  <alias from="folder_edit_form" to="@@properties.html"/>
+ <alias from="folder_localrole_form" to="@@sharing.html"/>
  <alias from="index.html" to="@@view.html"/>
  <alias from="view" to="@@view.html"/>
 </object>



More information about the checkins mailing list