Edgewall Software

Changes between Version 4 and Version 6 of CookBook/Configuration/SignedTickets


Ignore:
Timestamp:
(multiple changes)
Author:
(multiple changes)
Comment:
(multiple changes)

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/Configuration/SignedTickets

    v4 v6  
    2222}}}
    2323
     24=== Signed Resolution
     25
     26Add `signed` as a //Resolution// through the web admin page //Admin// -> //Ticket System// -> //Resolutions// (`/admin/ticket/resolution`), or using TracAdmin:
     27{{{#!sh
     28trac-admin $env resolution add signed
     29}}}
     30
    2431=== Sign workflow step
    2532
     
    2734{{{#!ini
    2835[ticket-workflow]
    29 sign = new -> closed
     36sign = new,assigned,accepted,reopened -> closed
     37sign.name = resolve
    3038sign.permissions = TICKET_SIGN
    3139sign.operations = set_resolution
    3240sign.set_resolution = signed
     41}}}
     42
     43You probably also want to configure the list of //Resolutions//
     44for other actions with a `set_resolution` operation, so
     45that the //Signed// resolution does not appear in the list.
     46
     47{{{#!ini
     48resolve.set_resolution = fixed, invalid, wontfix, duplicate, worksforme
    3349}}}
    3450
     
    3854
    3955{{{#!python
     56# -*- coding: utf-8 -*-
     57
    4058from trac.core import *
    4159from trac.perm import IPermissionPolicy
    4260from trac.ticket.model import Ticket
    4361
     62
    4463class ReadonlySignedTickets(Component):
    45       implements(IPermissionPolicy)
    4664
    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)
    5266
    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
    5679}}}
    5780
     
    6184[trac]
    6285permission_policies = ReadonlySignedTickets, ...
     86}}}
     87
     88Additional permissions can be specified in `allowed_actions`.
     89If 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')
    6393}}}
    6494
     
    91121If you want to use a `signed` ''status'' instead of a resolution, change the last two lines of code to:
    92122{{{#!python
    93           # ...
    94           if t['status'] == 'signed':
    95              return False
     123         # ...
     124        if t['status'] == 'signed':
     125            return False
    96126}}}
    97127And change the workflow step to: