Modify

Opened 7 years ago

Closed 12 months ago

#6285 closed defect (wontfix)

Combined two patches in #4720 and #6221.

Reported by: trac@… Owned by: ixokai
Priority: lowest Component: TicketCreationStatusPlugin
Severity: trivial Keywords:
Cc: Trac Release: 0.11

Description (last modified by rjollos)

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.""")

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

    # ITicketChangeListener methods 

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

        if self.owned_by_user_status: 
            if ticket['owner'] == ticket['reporter']:  
                status = self.owned_by_user_status 

        if not status and 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 

Attachments (1)

plugin.py (1.8 KB) - added by trac@… 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by trac@…

comment:1 Changed 12 months ago by rjollos

  • Description modified (diff)
  • Resolution set to wontfix
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Action
as closed The owner will remain ixokai.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.