Modify

Opened 6 years ago

Last modified 5 years ago

#3402 assigned enhancement

set_field_to_owner?

Reported by: jevans Owned by: retracile
Priority: normal Component: AdvancedTicketWorkflowPlugin
Severity: normal Keywords:
Cc: Trac Release: 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

Attachments (0)

Change History (2)

comment:1 Changed 5 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 5 years ago by retracile

  • Status changed from new to 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.

Add Comment

Modify Ticket

Action
as assigned The owner will remain retracile.
Author


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

 
Note: See TracTickets for help on using tickets.