Changeset 3628

Show
Ignore:
Timestamp:
05/06/08 21:59:45 (7 months ago)
Author:
retracile
Message:

AdvancedTicketWorkflowPlugin: Add set_owner_to_previous operation, bump version to 0.2.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • advancedticketworkflowplugin/0.11

    • Property svn:ignore set to
      build
      dist
      *.egg-info
  • advancedticketworkflowplugin/0.11/advancedworkflow/controller.py

    r3611 r3628  
    155155                                action + '.' + self._op_name).strip() 
    156156        return ticket[field] 
     157 
     158 
     159class TicketWorkflowOpOwnerPrevious(TicketWorkflowOpBase): 
     160    """Sets the owner to the previous owner 
     161 
     162    Don't forget to add the `TicketWorkflowOpOwnerPrevious` to the workflow 
     163    option in [ticket]. 
     164    If there is no workflow option, the line will look like this: 
     165 
     166    workflow = ConfigurableTicketWorkflow,TicketWorkflowOpOwnerPrevious 
     167    """ 
     168 
     169    _op_name = 'set_owner_to_previous' 
     170 
     171    # ITicketActionController methods 
     172 
     173    def render_ticket_action_control(self, req, ticket, action): 
     174        """Returns the action control""" 
     175        actions = ConfigurableTicketWorkflow(self.env).actions 
     176        label = actions[action]['name'] 
     177        new_owner = self._new_owner(ticket) 
     178        if new_owner: 
     179            hint = 'The owner will change to %s' % new_owner 
     180        else: 
     181            hint = 'The owner will be deleted.' 
     182        control = tag('') 
     183        return (label, control, hint) 
     184 
     185    def get_ticket_changes(self, req, ticket, action): 
     186        """Returns the change of owner.""" 
     187        return {'owner': self._new_owner(ticket)} 
     188 
     189    def _new_owner(self, ticket): 
     190        """Determines the new owner""" 
     191        db = self.env.get_db_cnx() 
     192        cursor = db.cursor() 
     193        cursor.execute("SELECT oldvalue FROM ticket_change WHERE ticket=%s " \ 
     194                       "AND field='owner' ORDER BY -time", (ticket.id, )) 
     195        row = cursor.fetchone() 
     196        if row: 
     197            owner = row[0] 
     198        else: # The owner has never changed. 
     199            owner = '' 
     200        return owner 
  • advancedticketworkflowplugin/0.11/setup.py

    r3611 r3628  
    55setup(   
    66        name='AdvancedTicketWorkflowPlugin', 
    7         version='0.1', 
     7        version='0.2', 
    88        author = 'Eli Carter', 
    99        author_email = 'elicarter@retracile.net',