Opened 10 years ago

# set_field_to_owner?

Reported by: Owned by: J Evan S Eli Carter normal AdvancedTicketWorkflowPlugin normal 0.11

### Description

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


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

I've achieved this in my local installation by adding the following code to controller.py:

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 8 years ago by Eli Carter

Status: new → assigned

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