Changeset 3632

Show
Ignore:
Timestamp:
05/07/08 23:05:22 (7 months ago)
Author:
retracile
Message:

AdvancedTicketWorkflowPlugin: Add 'set_status_to_previous' operation. Bump version to 0.4.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • advancedticketworkflowplugin/0.11/advancedworkflow/controller.py

    r3631 r3632  
    198198 
    199199 
     200class TicketWorkflowOpStatusPrevious(TicketWorkflowOpBase): 
     201    """Sets the status to the previous status 
     202 
     203    Don't forget to add the `TicketWorkflowOpStatusPrevious` to the workflow 
     204    option in [ticket]. 
     205    If there is no workflow option, the line will look like this: 
     206 
     207    workflow = ConfigurableTicketWorkflow,TicketWorkflowOpStatusPrevious 
     208    """ 
     209 
     210    _op_name = 'set_status_to_previous' 
     211 
     212    # ITicketActionController methods 
     213 
     214    def render_ticket_action_control(self, req, ticket, action): 
     215        """Returns the action control""" 
     216        actions = ConfigurableTicketWorkflow(self.env).actions 
     217        label = actions[action]['name'] 
     218        new_status = self._new_status(ticket) 
     219        if new_status != ticket['status']: 
     220            hint = 'The status will change to %s' % new_status 
     221        else: 
     222            hint = '' 
     223        control = tag('') 
     224        return (label, control, hint) 
     225 
     226    def get_ticket_changes(self, req, ticket, action): 
     227        """Returns the change of status.""" 
     228        return {'status': self._new_status(ticket)} 
     229 
     230    def _new_status(self, ticket): 
     231        """Determines the new status""" 
     232        db = self.env.get_db_cnx() 
     233        cursor = db.cursor() 
     234        cursor.execute("SELECT oldvalue FROM ticket_change WHERE ticket=%s " \ 
     235                       "AND field='status' ORDER BY -time", (ticket.id, )) 
     236        row = cursor.fetchone() 
     237        if row: 
     238            status = row[0] 
     239        else: # The status has never changed. 
     240            status = 'new' 
     241        return status 
     242 
     243 
    200244class TicketWorkflowOpRunExternal(Component): 
    201245    """Action to allow running an external command as a side-effect. 
  • advancedticketworkflowplugin/0.11/setup.py

    r3631 r3632  
    55setup(   
    66        name='AdvancedTicketWorkflowPlugin', 
    7         version='0.3', 
     7        version='0.4', 
    88        author = 'Eli Carter', 
    99        author_email = 'elicarter@retracile.net',