Opened 9 years ago

Last modified 7 years ago

#3402 assigned enhancement


Reported by: J Evan S Owned by: Eli Carter
Priority: normal Component: AdvancedTicketWorkflowPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11


How about a set_field_to_owner to complement set_owner_to_field?

fix = inprogress -> needs_review
fix.operations = set_field_to_owner
fix.set_field_to_owner = fixedby
fail = in_testing -> failed
fail.operations = set_owner_to_field
fail.set_owner_to_field = fixedby

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by david.shepherdson@…

I've achieved this in my local installation by adding the following code to

class TicketWorkflowOpFieldOwner(TicketWorkflowOpBase):
    """Sets the value of a ticket field to the owner

    <someaction>.operations = set_field_to_owner
    <someaction>.set_field_to_owner = myfield

    Don't forget to add the `TicketWorkflowOpFieldOwner` to the workflow
    option in [ticket].
    If there is no workflow option, the line will look like this:

    workflow = ConfigurableTicketWorkflow,TicketWorkflowOpFieldOwner

    _op_name = 'set_field_to_owner'

    # ITicketActionController methods

    def render_ticket_action_control(self, req, ticket, action):
        """Returns the action control"""
        actions = ConfigurableTicketWorkflow(self.env).actions
        label = actions[action]['name']
        hint = 'The %s will change to %s' % (self._field_name(action, ticket), ticket['owner'])
        control = tag('')
        return (label, control, hint)

    def get_ticket_changes(self, req, ticket, action):
        """Returns the change of the field."""
        return {self._field_name(action, ticket): ticket['owner']}

    def _field_name(self, action, ticket):
        """Determines the new owner"""
        field = self.config.get('ticket-workflow',
                                action + '.' + self._op_name).strip()
        return field

To get it to work properly, I'm also hiding the field in question using the BlackMagicTicketTweaksPlugin; without that, I was getting complaints about the field being set twice when a user submitted the form.

comment:2 Changed 7 years ago by Eli Carter

Status: newassigned

The need to hide the field hints at a deeper problem in Trac core which I need to dig into. I'm inclined to postpone adding this feature here until I figure out a good solution for the underlying issue in core, but it is very clearly a good idea.

Modify Ticket

Change Properties
Set your email in Preferences
as assigned The owner will remain Eli Carter.

Add Comment

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

Note: See TracTickets for help on using tickets.