Permalink
Browse files

Workflow panel

  • Loading branch information...
optilude committed Nov 11, 2011
1 parent 3c71e8d commit 1ba22bd4765395d355b00ae8d69739b7e4eff0fd
View
@@ -79,8 +79,9 @@ Context
Workflow
--------
- [ ] State(s)
- [ ] Workflow name(s)
+ [x] State(s)
+ [x] Workflow name(s)
+ [x] Permission matrix
Logging
-------
@@ -81,4 +81,13 @@
layer=".interfaces.IDebugToolbarLayer"
/>
+ <browser:viewlet
+ name="plone.app.debugtoolbar.workflow"
+ manager=".interfaces.IDebugToolbarViewletManager"
+ class=".workflow.WorkflowViewlet"
+ template="workflow.pt"
+ permission="zope2.View"
+ layer=".interfaces.IDebugToolbarLayer"
+ />
+
</configure>
@@ -0,0 +1,54 @@
+<h2 class="debug-toolbar-header" id="debug-toolbar-workflow" i18n:translate="debug_toolbar_workflow_title">
+ Workflow <small>and security</small>
+ <span tal:condition="view/workflowStatus" id="debug-toolbar-workflow-status" i18n:name="method" class="label success" tal:content="view/workflowStatus" />
+</h2>
+
+<div class="debug-toolbar-body" id="debug-toolbar-workflow-body">
+
+ <p class="debug-toolbar-help">
+ This panel shows information about the workflow and security
+ of the current item.
+ </p>
+
+ <h3 i18n:translate="">Workflow information</h3>
+
+ <table class="zebra-striped">
+ <tbody>
+ <tr>
+ <td i18n:translate="">Workflow state(s)</td>
+ <td><code tal:repeat="state view/workflowStates" tal:content="state"/></td>
+ </tr>
+ <tr>
+ <td i18n:translate="">Workflow name(s)</td>
+ <td><code tal:repeat="name view/workflowNames" tal:content="name"/></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h3 i18n:translate="">Permission matrix</h3>
+
+ <table class="zebra-striped">
+ <thead>
+ <tr>
+ <th i18n:translate="">Name</th>
+ <th i18n:translate="">Acquire</th>
+ <td tal:repeat="role view/roles" tal:content="role" />
+ </tr>
+ </thead>
+ <tbody>
+ <tr tal:repeat="info view/permissionInfo">
+ <td>
+ <span tal:content="info/name" />
+ <span tal:condition="info/granted" class="label success" i18n:translate="">Granted</span>
+ <td>
+ <input type="checkbox" disabled="disabled" checked="python:info['acquired'] and 'checked' or None" />
+ </td>
+ <td tal:repeat="role info/roles">
+ <input type="checkbox" disabled="disabled" tal:attributes="checked python:role and 'checked' or None" />
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+
+</div>
@@ -0,0 +1,44 @@
+from zope.viewlet.viewlet import ViewletBase
+
+from AccessControl import getSecurityManager
+from Products.CMFCore.utils import getToolByName
+
+class WorkflowViewlet(ViewletBase):
+
+ def update(self):
+
+ # Workflow
+ workflow = getToolByName(self.context, 'portal_workflow')
+
+ self.workflowStatus = workflow.getInfoFor(self.context, 'review_state', None)
+
+ workflows = workflow.getWorkflowsFor(self.context)
+
+ self.workflowStates = [
+ workflow.getInfoFor(self.context, wf.state_var, None)
+ for wf in workflows
+ ]
+
+ self.workflowNames = [wf.getId() for wf in workflows]
+
+ # Permissions
+
+ self.roles = self.context.validRoles()
+ self.permissionInfo = []
+
+ sm = getSecurityManager()
+
+ for p in self.context.permission_settings():
+ name = p['name']
+ acquired = bool(p['acquire'])
+ granted = bool(sm.checkPermission(name, self.context))
+
+ roles = [r['selected'] == 'SELECTED'
+ for r in self.context.rolesOfPermission(name)]
+
+ self.permissionInfo.append({
+ 'name': name,
+ 'granted': granted,
+ 'acquired': acquired,
+ 'roles': roles,
+ })

0 comments on commit 1ba22bd

Please sign in to comment.