Changes between Initial Version and Version 1 of Ticket #9502, comment 1


Ignore:
Timestamp:
Aug 24, 2014, 5:10:56 AM (10 years ago)
Author:
Ryan J Ollos
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9502, comment 1

    initial v1  
    1 I've come up with an implementation that I would like to share. I have added this code to advancedworkflow/controller.py:
    2 {{{
    3 class TicketWorkflowOpFieldValue(TicketWorkflowOpBase):
    4     """Sets a ticket field to a fixed value
    5 
    6     <someaction>.operations = set_field_to_value
    7     <someaction>.set_field_to_value_field = myfield
    8     <someaction>.set_field_to_value_value = myvalue
    9 
    10     Don't forget to add the `TicketWorkflowOpFieldValue` to the workflow
    11     option in [ticket].
    12     If there is no workflow option, the line will look like this:
    13 
    14     workflow = ConfigurableTicketWorkflow,TicketWorkflowOpFieldValue
    15     """
    16 
    17     _op_name = 'set_field_to_value'
    18 
    19     # ITicketActionController methods
    20 
    21     def render_ticket_action_control(self, req, ticket, action):
    22         """Returns the action control"""
    23 
    24         actions = self.get_configurable_workflow().actions
    25         label = actions[action]['name']
    26         hint = ' The %s will change to %s ' % (self._get_field(action,ticket), self._get_value(action,ticket))
    27         control = tag('')
    28         return (label, control, hint)
    29 
    30     def get_ticket_changes(self, req, ticket, action):
    31         """Returns the change of owner."""
    32         return {self._get_field( action, ticket): self._get_value(action, ticket)}
    33 
    34     def _get_field(self, action, t5Aicket):
    35         """Determines the field to change"""
    36         field = self.config.get('ticket-workflow',
    37                                 action + '.' + self._op_name + '_field').strip()
    38         return field
    39 
    40     def _get_value(self, action, ticket):
    41         """Determines the new value"""
    42         value = self.config.get('ticket-workflow',
    43                                 action + '.' + self._op_name + '_value').strip()
    44         return value
    45 }}}
     1I've come up with an implementation that I would like to share. I have added this code to advancedworkflow/controller.py: [t9502.patch].