Modify

Opened 3 years ago

Last modified 3 years ago

#9502 new enhancement

set_field_to_value

Reported by: anonymous Owned by: retracile
Priority: normal Component: AdvancedTicketWorkflowPlugin
Severity: normal Keywords:
Cc: 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 (0)

Change History (2)

comment:1 Changed 3 years ago by anonymous

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

comment:2 Changed 3 years ago by anonymous

  • Type changed from defect to enhancement

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.