Changes between Version 10 and Version 11 of CookBook/PermissionPolicies
- Timestamp:
- May 8, 2017, 1:15:57 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook/PermissionPolicies
v10 v11 5 5 == Restrict a Workflow Action to the Ticket Owner 6 6 7 This permissions policy can be used to restrict a workflow action to the ticket 'sowner.7 This permissions policy can be used to restrict a workflow action to the ticket owner that possesses `TICKET_CHANGE_STATE`. User with `TICKET_ADMIN` can perform the action even if they are not the owner. 8 8 9 9 To install and activate the plugin: … … 25 25 from trac.core import * 26 26 from trac.perm import IPermissionPolicy, IPermissionRequestor 27 from trac.resource import ResourceNotFound 27 28 from trac.ticket.model import Ticket 28 29 … … 47 48 resource.realm == 'ticket' and \ 48 49 resource.id is not None: 49 ticket = Ticket(self.env, resource.id) 50 return ticket['owner'] == username 51 return None 50 try: 51 ticket = Ticket(self.env, resource.id) 52 except ResourceNotFound: 53 pass 54 else: 55 if ticket['owner'] != username: 56 return 'TICKET_ADMIN' in perm 52 57 }}} 53 58 1. Edit the `permission_policies` option in the [TracIni#trac-section "[trac]"] section of trac.ini, adding the `RestrictTicketActions` component ''before'' the default [TracPermissions permission] policy: