Arrange Fields in Trac Tickets

I was struggling one day to organize fields in the order I want when I create tickets in Trac.

  1. Copy templates/ticket.html into trac/myproject/templates/ticket.html
  2. Insert the following code snippet to the beginning of the template:
  3. <?python
      # define the order
      field_types = ["type", "priority", "milestone",  "keywords", "cc",  "component"]
    
      # Sorting function
      def sort_nicely(field1, field2):
        try:
            idx1 = field_types.index(field1['name'])
        except ValueError:
            idx1 = 1000 # no match, push to the end
    
        try:
            idx2 = field_types.index(field2['name'])
        except ValueError:
            idx2 = 1000 # no match, push to the end
    
        return cmp(idx1, idx2)
    
      fields.sort(cmp=sort_nicely)
    ?>
    

That’s it, if you have any custom fields and you want them ordered, put them into the field_types list.

34 Responses to “Arrange Fields in Trac Tickets”

  1. kaca Says:

    Hi, I copied this code into the templates/ticket.html and where I must call the sorting function when I want to order the fields for create new ticket?
    Thanks
    K

  2. taroza Says:

    The above code already calls that function for you in the last line.

    The “fields” list comes from the templating engine and then it’s sorted according to the order in the “field_types” list.

  3. kaca Says:

    thanks, I copied, inserted code to the but any changes of the order my fields.

  4. taroza Says:

    Well, either you didn’t define “field_types” properly, or the code is not in the right ticket.html, or the old template is compiled and cached somewhere.

  5. kaca Says:

    oh.now it’s all right.
    Thank you very much

  6. Bangyou Zheng Says:

    Thank you very much. Your codes are wonderful.

  7. matteo Says:

    thanks for the good work and to make it available to all.
    I have found out that fields’ name have to be all lower case for this to work properly (I have custom fields).

  8. Rearranging Ticket Fields in Trac | Fleeblewidget Says:

    […] Full instructions are available here. […]

  9. προσφορές Says:

    It’s a shame you don’t have a donate button!
    I’d most certainly donate to this outstanding blog! I guess for now i’ll settle for bookmarking
    and adding your RSS feed to my Google account. I look forward to new updates and will share
    this website with my Facebook group. Talk soon!

  10. top nursing colleges in michigan Says:

    Woah! I’m really digging the template/theme of this website. It’s simple, yet effective.
    A lot of times it’s hard to get that “perfect balance” between superb usability and visual appeal. I must say that you’ve done a fantastic
    job with this. Additionally, the blog loads extremely quick for me
    on Firefox. Excellent Blog!

  11. ellen Says:

    I seem to be missing the default ticket.html, and have tired to google for it with out success, Could you post one here as well?

  12. ellen Says:

    found the file… looked in the wrong place, sorry. However I’m still only able to re-order cc fields, type etc, how about Description and Summary is it supposed to work for these too?

  13. Steve Says:

    Hi, This is a good fix, and I have used it successfully on a few projects we have here at proteanelectric.com. However I don’t appear to be able to re-order summary or description either. I can can live with that however, and it is a useful add-on.

  14. ellen Says:

    Hmm, one more problem. Just noticed that after adding the ticket.html I’m not able to make any changes to the ticket due to “The ticket has been modified by someone else …”, something additional needed to be done when adding the ticket.html file in the tempalte directory?

  15. www Says:

    Hello, Neat post. There is a problem along with your site in web explorer,
    might check this? IE still is the market leader and a good section
    of folks will miss your great writing due to this problem.

  16. forexground.pl Says:

    Hello my loved one! I wish to say that this article is amazing,
    nice written and include approximately all important infos.
    I’d like to see extra posts like this .

  17. how to renew european health insurance card Says:

    Thanks , I have recently been searching for information approximately this
    subject for ages and yours is the greatest I have found out so
    far. However, what in regards to the conclusion? Are you
    sure about the source?

  18. powerade Ion4 sports drink coupons Says:

    Thanks for sharing your thouǥhts on powerade 8 pack coupons.
    Ʀegards

  19. Www.Gatorade Coupons Says:

    WOW just whɑt I was searching fօr. Cɑme here bƴ searching fߋr gatorade coupoons
    printable coupons

  20. Raymond Says:

    You can definitely see your enthusiasm within the article you write.
    The world hopes for even more passionate writers like you who are
    not afraid to say how they believe. Always go after your heart.

  21. junk cars bronx ny Says:

    There are a few points and tips that one has to keep in mind when going
    to car junkyard. A couple of the companies listed are only interested in wrecked or non-working newer cars but there are wreckers who will take the older vehicles for parts.
    These corporations get gain out of these vehicles and in return, give deserving
    amount of money of money to the proprietors of these junk or wrecked automobiles.

  22. paket susu domba Says:

    Perhaps you will be inspired to confront a friend or even yourself about an important decision. Now comes
    cosmetic way, while using cosmetic one should be careful and use the product ensured by the experts.
    Summer is one of the seasons when you’ll have the most
    fun.

  23. healthbodycare.com Says:

    I think what you posted was very reasonable.

    But, what about this? what if you were to write a awesome
    title? I mean, I don’t want to tell you how to
    run your website, however suppose you added a post title that makes people want more?
    I mean Arrange Fields in Trac Tickets | My Perspective is a
    little plain. You might glance at Yahoo’s front page and note how they create article titles to get viewers to click.
    You might add a video or a pic or two to get people excited about what
    you’ve got to say. In my opinion, it could bring your
    blog a little bit more interesting.

  24. leasing samochodu osobowego w 2014 roku a vat Says:

    Using bad credit auto loans, a person with a bad credit history are able to
    use it to begin fixing as well as improving their report history.

    Most secured car finance packages have fixed interest rates but
    personal loans can be variable. If you are a
    first time applicant for student car loans, there is no reason for you to
    panic. In situation of purchase new car, SBI car loan is provided on any model of carmaker and in situation of buy old
    car, SBI Car Loan will provide on any make or design, however the
    car shouldn’t be beyond 5 years old. This is often a nice beginning to improving your credit history.
    The day count convention is a system by which the number of days is
    determined between coupon dates or settlement dates and is then used to calculate the interest accrued during
    this period of time.

  25. Free Cash Formula Says:

    I know this website provides quality based
    articles and other stuff, is there any other web page which provides these kinds
    of information in quality?

  26. cara menurunkan berat badan Says:

    Tebu (bahasa Inggris: sugar cane) adalah tanaman yang ditanam untuk
    bahan baku gula dan vetsin. Yang berarti , karena Anda dapat menemukan ,
    itu punya penuh keseimbangan tentang apa Anda akan mengharapkan. Consequently, why
    might an individual be able in order to claim back your own Insurance monthly
    premiums.

  27. Ron Kadarishko Says:

    If you want to get a great deal from this
    article then you have to apply these techniques to your won weblog.

  28. batu bacan doko murah Says:

    Molten Silica spit flies from a historical rhyolite crater and flies into volcanic ash (silica
    powder) and rolls down hill to round it. At the
    Byron Bay, began in the and temperate waters unite rendering it
    an excellent area for snorkeling and deep-sea diving for your tourists.
    5, temperature: the actual agate is cool in summer and warm in the winter months, but the temperature of fake agate isn’t maintained internally the way is, but fluctuates while using temperature with their environment.

  29. si affacciano mobili Says:

    Sono venire rassegna concernente marchi e decidere concernente la mia personale operative , è
    pratico ottenere molti suggerimenti in questo articolo .

  30. tempat wisata bogor Says:

    Hello, the whole thing is going nicely here and ofcourse every
    one is sharing information, that’s really good, keep up writing.

  31. cheap student storage Says:

    Hi there! This bblog post ould not be written any better!
    Reading through this poet reminds me of my previous roommate!
    He always kept preaching about this. I will forward this article to
    him. Fairly certain he’s going tto have a very
    good read. I appreciate you for sharing!

  32. Bahria Town Lahore Real Estate Agent Says:

    This paragraph is genuinely a pleasant one it helps new internet
    users, who are wishing in favor of blogging.

  33. Free Porn at PornManiak Says:

    Hi, i feel that i saw you visited my blog thus i got here to return the want?.I am trying to to find things to improve my
    website!I guess its ok to make use of some of your ideas!!

  34. Delila Says:

    A continuación nos vamos a la página específica de una apuesta en Una vez plenamente cargada
    la página y veamos que nos aparecen pujas de usuarios, pulsamos
    el enlace creado en favoritos. Esto nos cargará el script,
    mas ahora falta ponerlo en funcionamiento. http://www.getjealous.com/salazarluaclpokdt/journal/5041907/de-qu-manera-funciona-una-subasta-on-lin.html


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: