Modify

Opened 15 years ago

Closed 9 years ago

Last modified 9 years ago

#6221 closed enhancement (wontfix)

different starting states for different ticket types

Reported by: zooli Owned by: Stephen Hansen
Priority: normal Component: TicketCreationStatusPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description (last modified by Ryan J Ollos)

I've modified a little bit your code, to have the ability to use different starting states for different ticket types.

The code is:

from trac.core import Component, implements
from trac.ticket.api import ITicketChangeListener
from trac.config import Option

def get_type_default(raw_options, type):
    for option, value in raw_options:
        if option == 'default_' + type:
            return value
            
    return None

class TicketCreationStatus(Component):
    implements(ITicketChangeListener)
    
    default_status = Option('ticketcreationstatus', 'default', None, 
        doc="""Determines the status for tickets (if not otherwise modified).""")

    owned_status = Option('ticketcreationstatus', 'owned', None, 
        doc="""Determines the status for tickets that start out owned.""")

    def ticket_created(self, ticket):
        status = None
        default_type_status = get_type_default(self.config.options('ticketcreationstatus'), ticket['type'])
        
        if self.owned_status:     
            if ticket['owner']:
                status = self.owned_status
        
        if not status and default_type_status:
            status = default_type_status

        if not status and self.default_status:
            status = self.default_status

        if status is not None:
            db = self.env.get_db_cnx()
            cursor = db.cursor()
            cursor.execute("update ticket set status=%s where id=%s", (status, ticket.id))
            db.commit()

    def ticket_changed(self, ticket, comment, author, old_values):
        pass

    def ticket_deleted(self, ticket):
        pass 

usage:

default_%type% = %defaultfortype%

Attachments (0)

Change History (1)

comment:1 Changed 9 years ago by Ryan J Ollos

Description: modified (diff)
Resolution: wontfix
Status: newclosed

Plugin is deprecated. The upcoming Trac 1.2 has equivalent functionality. See the TicketCreationStatusPlugin page for more info.

This feature request would be handled by using MultipleWorkflowPlugin with Trac 1.2.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Stephen Hansen.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.