Opened 12 years ago
Last modified 3 years ago
#9502 accepted enhancement
set_field_to_value
| Reported by: | anonymous | Owned by: | Ryan J Ollos |
|---|---|---|---|
| Priority: | normal | Component: | AdvancedTicketWorkflowPlugin |
| Severity: | normal | Keywords: | |
| Cc: | David Bonnin | Trac Release: | 0.12 |
Description
The workflow in our organization knows a 'review_by_architect' state and a 'submit_to_testing'. With both actions leading to these states, our developers set the next owner manually for each ticket. Because both architect and testing each have a single, fixed account, we would greatly benefit from this action
set_field_to_value (TicketWorkflowOpFieldValue)
Sets a ticket field to a value specified in trac.ini
<someaction>.operations = set_field_to_value
<someaction>.set_field_to_value.field = mycustomfield
<someaction>.set_field_to_value.value = peter
Attachments (2)
Change History (9)
comment:2 Changed 12 years ago by
| Type: | defect → enhancement |
|---|
comment:3 Changed 9 years ago by
#6921 was closed as a duplicate. The ticket has requested the ability to move a custom ticket field to the workflow section so the user would be forced to fill in a value.
Changed 9 years ago by
| Attachment: | t9951.patch added |
|---|
comment:4 Changed 9 years ago by
What is needed is the ability to add, delete, append to or remove from a field. The following tickets requested those operations for various fields:
- #5552 requested the ability to append to the CC field
- #7771 requested the ability to add keywords (provides a patch)
- #9251 requested the ability to delete a field (provides a patch).
- #9951 requested the ability to set the Type field (provides a patch).
- #10457 requested the ability to set the Version and Milestone fields.
See also trac:#11452.
Changed 9 years ago by
comment:5 Changed 3 years ago by
| Cc: | David Bonnin added |
|---|
comment:6 Changed 3 years ago by
| Owner: | Eli Carter deleted |
|---|
comment:7 Changed 3 years ago by
| Owner: | set to Ryan J Ollos |
|---|---|
| Status: | new → accepted |



I've come up with an implementation that I would like to share. I have added this code to advancedworkflow/controller.py:
class TicketWorkflowOpFieldValue(TicketWorkflowOpBase): """Sets a ticket field to a fixed value <someaction>.operations = set_field_to_value <someaction>.set_field_to_value_field = myfield <someaction>.set_field_to_value_value = myvalue Don't forget to add the `TicketWorkflowOpFieldValue` to the workflow option in [ticket]. If there is no workflow option, the line will look like this: workflow = ConfigurableTicketWorkflow,TicketWorkflowOpFieldValue """ _op_name = 'set_field_to_value' # ITicketActionController methods def render_ticket_action_control(self, req, ticket, action): """Returns the action control""" actions = self.get_configurable_workflow().actions label = actions[action]['name'] hint = ' The %s will change to %s ' % (self._get_field(action,ticket), self._get_value(action,ticket)) control = tag('') return (label, control, hint) def get_ticket_changes(self, req, ticket, action): """Returns the change of owner.""" return {self._get_field( action, ticket): self._get_value(action, ticket)} def _get_field(self, action, t5Aicket): """Determines the field to change""" field = self.config.get('ticket-workflow', action + '.' + self._op_name + '_field').strip() return field def _get_value(self, action, ticket): """Determines the new value""" value = self.config.get('ticket-workflow', action + '.' + self._op_name + '_value').strip() return value