Version 3 (modified by 10 years ago) ( diff ) | ,
---|
Signed Tickets
Some projects require a special workflow where tickets can be signed.
This recipe shows steps to implement various aspects of such a feature using a combination of configuration, existing plugins and a small custom permission policy containing the authorization rules.
Goals
- Users with
TICKET_SIGN
permission can sign tickets. - Signed tickets are considered closed with resolution
signed
. - Signed tickets are read only, except to users with
TICKET_ADMIN
permission. - Signed tickets are visually distinguished.
Steps
TICKET_SIGN permission
Enable the optional component ExtraPermissionsProvider and configure a new permission:
[extra-permissions] _perms = TICKET_SIGN
Sign workflow step
Configure your workflow adding a step to resolve as signed:
[ticket-workflow] sign = new -> closed sign.permissions = TICKET_SIGN sign.operations = set_resolution sign.set_resolution = signed
Readonly logic
Create a single file plugin that implements IPermissionPolicy:
from trac.core import * from trac.perm import IPermissionPolicy from trac.ticket.model import Ticket class ReadonlySignedTickets(Component): implements(IPermissionPolicy) def check_permission(self, action, username, resource, perm): if resource is None or resource.realm != 'ticket' or \ resource.id is None or action == 'TICKET_VIEW' or \ action == 'TICKET_ADMIN' or 'TICKET_ADMIN' in perm: return None t = Ticket(self.env, resource.id) if t['status'] == 'closed' and t['resolution'] == 'signed': return False
Configure the component before the default permission policy:
[trac] permission_policies = ReadonlySignedTickets, ...
Visual indication
- Install th:ContextChromePlugin#TicketcolorbyType and enable it:
[components] contextchrome.style.typeclasstoticket = enabled
- Configure it to decorate based on the ticket's resolution:
[ticket] decorate_fields = resolution
- Add site.html (the first code snippet in that section) to your Environment templates directory.
- Add
style.css
to your Environment htdocs directory. Add CSS using the selectorbody.resolution_is_signed
. For example:body.resolution_is_signed { background: #f5deb3 url(signed.png); }
- Add signed.png to the htdocs directory.
Variations
Allow ticket comments
If you still want to allow commenting on signed tickets, change action == 'TICKET_VIEW'
to action in ['TICKET_VIEW', 'TICKET_APPEND']
.
Status instead of resolution
If you want to use a signed
status instead of a resolution, change the last two lines of code to:
# ... if t['status'] == 'signed': return False
And change the workflow step to:
[ticket-workflow] sign = closed -> signed sign.permissions = TICKET_SIGN
And configure signed
as an end state for milestone progress:
[milestone-groups] closed = closed,signed
Change resolution to status in the visual steps.
Attachments (1)
- signed.png (2.5 KB ) - added by 10 years ago.
Download all attachments as: .zip