From: optilude <svn...@pl...> - 2006-12-31 02:30:29
|
Author: optilude Date: Sun Dec 31 02:30:26 2006 New Revision: 11830 Modified: plone.app.workflow/trunk/plone/app/workflow/browser/sharing.pt plone.app.workflow/trunk/plone/app/workflow/browser/sharing.py Log: Listing now mostly works. The update() handler is still not actually making any changes and the form parameters probably need to be modified before it can be made to work. User/group search-and-add is also missing. Modified: plone.app.workflow/trunk/plone/app/workflow/browser/sharing.pt ============================================================================== --- plone.app.workflow/trunk/plone/app/workflow/browser/sharing.pt (original) +++ plone.app.workflow/trunk/plone/app/workflow/browser/sharing.pt Sun Dec 31 02:30:26 2006 @@ -45,17 +45,64 @@ <table class="listing" summary="Current sharing permissions" + tal:define="available_roles view/roles" i18n:attributes="summary summary_assigned_roles;"> <thead> <tr> <th i18n:translate="label_name">User/Group</th> - <th class="nosort">Read</th> - <th class="nosort">Edit</th> - <th class="nosort">Review</th> + <th class="nosort" + tal:repeat="role available_roles" + tal:content="role/title" /> </tr> </thead> + <tbody> + <tal:entries repeat="entry view/role_settings"> + <tr class="odd" + tal:define="is_group python:entry['type'] == 'group'" + tal:attributes="class python:repeat['entry'].odd and 'odd' or 'even'"> + <td> + <img tal:condition="is_group" tal:replace="structure here/group.gif" /> + <img tal:condition="not:is_group" tal:replace="structure here/user.gif" /> + <span tal:replace="entry/title" /> + <input + type="hidden" + tal:attributes="name string:entries.${entry/id}.id:dict:list; + value entry/id" + + /> + <input + type="hidden" + tal:attributes="name string:entries.${entry/id}.type:dict:list; + value entry/type" + + /> + </td> + <td tal:repeat="role available_roles"> + <tal:block define="entry_role python:entry['roles'][role['id']]"> + <input + type="hidden" + tal:attributes="name string:roles.${role/id}.default:dict:list; + value entry_role" + + /> + <img tal:condition="python:entry_role is None" tal:replace="structure here/confirm_icon.gif"> + <tal:block condition="python:entry_role is not None"> + <input + type="checkbox" + value="True" + tal:attributes="name string:roles.${role/id}.value:dict:list; + checked python:entry_role == True and 'checked' or None" + + /> + </tal:block> + </tal:block> + </td> + </tr> + </tal:entries> + </tbody> + <!-- Items to note about this section: - The placeholder text should of course disappear when the field is selected (I have asked Florian to come up with a generic solution to this). @@ -72,48 +119,23 @@ id="user-group-search" size="30" style="color: #666" + name="search_term" value="Type here to add user/group" /> <noscript> - <input type="submit" - value="Search" - class="searchButton" /> + <input type="submit" + name="form.button.Search" + value="Search" + class="searchButton" /> </noscript> </td> </tr> </tfoot> - - <tbody> - <tr class="odd"> - <td>Everyone</td> - <td><img tal:replace="structure here/confirm_icon.gif" /></td> - <td><input type="checkbox" /></td> - <td><input type="checkbox" /></td> - </tr> - <tr class="even"> - <td>Logged-in users</td> - <td><img tal:replace="structure here/confirm_icon.gif" /></td> - <td><input type="checkbox" /></td> - <td><input type="checkbox" /></td> - </tr> - <tr class="odd"> - <td><a href=""><img tal:replace="structure here/group.gif" /> Documentation Team</a></td> - <td><img tal:replace="structure here/confirm_icon.gif" /></td> - <td><img tal:replace="structure here/confirm_icon.gif" /></td> - <td><img tal:replace="structure here/confirm_icon.gif" /></td> - </tr> - <tr class="even"> - <td><a href=""><img tal:replace="structure here/user.gif" /> John Smith</a></td> - <td><input type="checkbox" checked="checked" /></td> - <td><input type="checkbox" checked="checked" /></td> - <td><input type="checkbox" /></td> - </tr> - </tbody> </table> <div class="field"> <input class="noborder" type="checkbox" - name="inherit:int" + name="inherit:boolean" value="1" checked="checked" id="inherit" Modified: plone.app.workflow/trunk/plone/app/workflow/browser/sharing.py ============================================================================== --- plone.app.workflow/trunk/plone/app/workflow/browser/sharing.py (original) +++ plone.app.workflow/trunk/plone/app/workflow/browser/sharing.py Sun Dec 31 02:30:26 2006 @@ -66,7 +66,7 @@ return [dict(id='Reader', title='View'), dict(id='Editor', title='Edit'), - dict(id='Reviewer', title='Reviewer')] + dict(id='Reviewer', title='Review')] @memoize def role_settings(self): @@ -79,11 +79,13 @@ - type (one of 'group' or 'user') - roles - 'roles' is a list of settings, one per role as returned by roles(), - each containing the values True if the role is explicitly set, False + 'roles' is a dict of settings, with keys of role ids as returned by + roles(), and values True if the role is explicitly set, False if the role is explicitly disabled and None if the role is inherited. """ + context = aq_inner(self.context) + portal_membership = getToolByName(aq_inner(self.context), 'portal_membership') portal_groups = getToolByName(aq_inner(self.context), 'portal_groups') portal = getToolByName(aq_inner(self.context), 'portal_url').getPortalObject() @@ -126,11 +128,11 @@ # Also, recut roles in the format specified in the docstring for d in dec_users: - item = a[-1] + item = d[-1] info_item = dict(id = item['id'], type = item['type'], title = item['name'], - roles = []) + roles = {}) # Use full name if possible if not item['type'] == 'group': @@ -140,12 +142,12 @@ # Record role settings for r in available_roles: - if r in info['acquired']: - info_item['roles'].append(None) - elif r in info['local']: - info_item['roles'].append(True) + if r in item['acquired']: + info_item['roles'][r] = None + elif r in item['local']: + info_item['roles'][r] = True else: - info_item['roles'].append(False) + info_item['roles'][r] = False info.append(info_item) |