| 7 | |
| 8 | == API Requirements == |
| 9 | |
| 10 | === Control of action transitions === |
| 11 | |
| 12 | * This interface should be stackable (useful eg. with a `DeleteTicket` plugin which adds a single 'delete' action, which can be used in conjunction with a full workflow replacement plugin). |
| 13 | * Plugins should register which actions they handle, and then handle them when requested to do so. |
| 14 | * Ensure that the user has sufficient permission to perform this action. |
| 15 | |
| 16 | === Control of ticket fields === |
| 17 | |
| 18 | * Manipulate custom/built-in fields via plugin architecture. eg. hiding existing fields, changing their attributes, etc. An example of this is the `DuplicateField` plugin which removes the "duplicate" status from the "resolve" action and adds a new action "resolve as xxx". |
| 19 | * Pluggable field types, eg. percentage bar, checkbox set, numeric input field, dollar field, etc. |
| 20 | |
| 21 | === Validation === |
| 22 | |
| 23 | * Validation of ticket date before being committed to the database. |
68 | | For more complex ticket workflow requirements two extension points are available, |
69 | | allowing full control of the ticket workflow process. |
70 | | |
71 | | {{{ |
72 | | #!python |
73 | | class ITicketManipulator(Interface): |
74 | | """ |
75 | | ITicketManipulator implementations are used to perform filtering of |
76 | | visible fields and validation. |
77 | | """ |
78 | | |
79 | | def filter_fields(req, ticket, fields): |
80 | | """ Filter a list of Field objects in place. Called just prior to |
81 | | ticket display. """ |
82 | | |
83 | | def filter_actions(req, ticket, actions): |
84 | | """ Filter a list of ticket actions and controls in place. `actions` is |
85 | | an list of tuples in the form (action, label, controls). """ |
86 | | |
87 | | def validate_ticket(req, ticket): |
88 | | """ Validate a ticket. Called just before the ticket is updated with |
89 | | user supplied values from req.args. """ |
90 | | |
91 | | class ITicketFieldProvider(Interface): |
92 | | """ Provide custom ticket fields programmatically. """ |
93 | | |
94 | | def get_custom_fields(): |
95 | | """ Return an iterable of trac.ticket.field.Field objects. """ |
96 | | |
97 | | class ITicketWorkflow(Interface): |
98 | | """ This interface controls what actions can be performed on a ticket. """ |
99 | | |
100 | | def get_actions(req, ticket): |
101 | | """ Return the actions that are available given the current state of |
102 | | ticket and the request object provided. """ |
103 | | |
104 | | def get_action_controls(req, ticket, action): |
105 | | """ Return an iterable of tuples in the form (label, controls), where |
106 | | controls is a list of trac.ticket.field.Field objects. """ |
107 | | |
108 | | def apply_action(req, ticket, action): |
109 | | """ Perform action on ticket. """ |
110 | | }}} |
| 85 | See the [source:sandbox/workflow/trac/ticket/api.py source] for extension points. |