Search code examples
pythonversion-controlinitrac

Display ticket type Trac


I can set "ticket type" when I create/modify a ticket and I can custom query and sort using the type, but it just doesn't display on the ticket's wiki page. The first thing that comes to mind is to modify the ticket template page, but then I quickly realized I had no idea what I was doing :). The next thing I thought of was to change trac.ini and add parameters to [ticket-custom]. I was able to add a label but I'm not sure how to get the value from the database. The query would be SELECT type FROM ticket WHERE id='ticket_num';. There may be a trac-admin command but I don't know it. Any help, tip, plugin, etc would be greatly appreciated.

Requirement:

I need to add the "ticket type" to the tickets wiki page.

Version of Trac:

1.0.1


Solution

  • The page you mention is the ticket view page. Its URL path is patterned <trac-base>/ticket/<ticket_no>.

    This is NOT a wiki page. The ticket type is certainly visible on that page, just look at the page title. By default it is a sequence of

    **<ticket_no>** <status> <ticket_type>
    

    Finally, you don't need to hack Trac for customizing that view. As with almost any other page it has a Genshi template, that can be replaced by a custom copy of the same file name in /templates/. The base template for ticket view is ticket/templates/ticket.html, that holds the ticket property editor too, with additional includes for

    • layout.html (general site appearance - Trac main navigation, footer, etc.)
    • ticket_box.html (current ticket properties in colored box at top of page)
    • list_of_attachments.html (you guess it, attachments list plus 'add attachment button')
    • ticket_change.html (the ticket change history section)
    • another ticket box, when in preview mode

    Choose, copy and customize templates as you want, but always remember that. Custom templates are one of the most common recurring issues when it comes to Trac environment upgrades due to backwards-incompatible template changes in upstream versions.