Changes between Version 4 and Version 6 of CookBook/Configuration/SignedTickets
- Timestamp:
- (multiple changes)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook/Configuration/SignedTickets
v4 v6 22 22 }}} 23 23 24 === Signed Resolution 25 26 Add `signed` as a //Resolution// through the web admin page //Admin// -> //Ticket System// -> //Resolutions// (`/admin/ticket/resolution`), or using TracAdmin: 27 {{{#!sh 28 trac-admin $env resolution add signed 29 }}} 30 24 31 === Sign workflow step 25 32 … … 27 34 {{{#!ini 28 35 [ticket-workflow] 29 sign = new -> closed 36 sign = new,assigned,accepted,reopened -> closed 37 sign.name = resolve 30 38 sign.permissions = TICKET_SIGN 31 39 sign.operations = set_resolution 32 40 sign.set_resolution = signed 41 }}} 42 43 You probably also want to configure the list of //Resolutions// 44 for other actions with a `set_resolution` operation, so 45 that the //Signed// resolution does not appear in the list. 46 47 {{{#!ini 48 resolve.set_resolution = fixed, invalid, wontfix, duplicate, worksforme 33 49 }}} 34 50 … … 38 54 39 55 {{{#!python 56 # -*- coding: utf-8 -*- 57 40 58 from trac.core import * 41 59 from trac.perm import IPermissionPolicy 42 60 from trac.ticket.model import Ticket 43 61 62 44 63 class ReadonlySignedTickets(Component): 45 implements(IPermissionPolicy)46 64 47 def check_permission(self, action, username, resource, perm): 48 if resource is None or resource.realm != 'ticket' or \ 49 resource.id is None or action == 'TICKET_VIEW' or \ 50 action == 'TICKET_ADMIN' or 'TICKET_ADMIN' in perm: 51 return None 65 implements(IPermissionPolicy) 52 66 53 t = Ticket(self.env, resource.id) 54 if t['status'] == 'closed' and t['resolution'] == 'signed': 55 return False 67 allowed_actions = ('TICKET_VIEW',) 68 69 def check_permission(self, action, username, resource, perm): 70 if resource is None or resource.realm != 'ticket' or \ 71 resource.id is None or \ 72 action in self.allowed_actions or \ 73 action == 'TICKET_ADMIN' or 'TICKET_ADMIN' in perm: 74 return None 75 76 t = Ticket(self.env, resource.id) 77 if t['status'] == 'closed' and t['resolution'] == 'signed': 78 return False 56 79 }}} 57 80 … … 61 84 [trac] 62 85 permission_policies = ReadonlySignedTickets, ... 86 }}} 87 88 Additional permissions can be specified in `allowed_actions`. 89 If you wish to allow commenting on signed tickets, add 90 `TICKET_APPEND` to the `allowed_actions`: 91 {{{#!python 92 allowed_actions = ('TICKET_VIEW', 'TICKET_APPEND') 63 93 }}} 64 94 … … 91 121 If you want to use a `signed` ''status'' instead of a resolution, change the last two lines of code to: 92 122 {{{#!python 93 94 95 123 # ... 124 if t['status'] == 'signed': 125 return False 96 126 }}} 97 127 And change the workflow step to: