Edgewall Software

Opened 12 years ago

Last modified 6 years ago

#10633 new enhancement

TicketQuery 'clist' format

Reported by: branson@… Owned by:
Priority: normal Milestone: next-major-releases
Component: wiki system Version:
Severity: normal Keywords: ticketquery
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


I had a need for a short delimited list that was more than 'compact' and 'list'; but less than 'table'. I am typically using this in a sidebar to get a current list of tickets with more useful information. The coding may be horid, as i am not a python programmer most days; but it works and gives a very useful function if you want to add it.

Index: trac/ticket/query.py
--- trac/ticket/query.py	(revision 1322)
+++ trac/ticket/query.py	(working copy)
@@ -1332,6 +1332,24 @@
                 alist = [ticket_anchor(ticket) for ticket in tickets]
                 return tag.span(alist[0], *[(', ', a) for a in alist[1:]])
+	elif format == 'clist':
+            if query.group:
+                return tag.div(
+                    [(tag.p(tag_('%(groupvalue)s %(groupname)s tickets:',
+                                 groupvalue=tag.a(v, href=href, class_='query',
+                                                  title=title),
+                                 groupname=query.group)),
+                      tag.dl([(tag.dt(ticket_anchor(t)), 
+                               tag.dd(' - '.join(map((lambda x:t[x].__str__()),kwargs['col'].split('|'))) )) for t in g],
+                             class_='wiki compact'))
+                     for v, g, href, title in ticket_groups()])
+            else:
+                return tag.div(tag.dl([(tag.dt(ticket_anchor(ticket)), 
+                                        tag.dd(' - '.join(map((lambda x:ticket[x].__str__()),kwargs['col'].split('|'))) ))
+                                       for ticket in tickets],
+                                      class_='wiki compact'))
             if query.group:
                 return tag.div(

Attachments (2)

Screen shot 2012-03-19 at 2.14.01 PM.png (67.3 KB ) - added by branson@… 12 years ago.
Screen shot of format=clist in action
T10633-TicketQuery-list-format.patch (4.7 KB ) - added by Peter Suter 12 years ago.
Adds col and template parameters to list format

Download all attachments as: .zip

Change History (7)

by branson@…, 12 years ago

Screen shot of format=clist in action

comment:1 by branson@…, 12 years ago

The screen shot was created using

= Upcoming Demos = 
= Current Operations =
[[TicketQuery(format=clist,col=owner|summary, group=milestone,type=log,status!=closed,milestone!=)]]

as an example.

Last edited 12 years ago by Remy Blank (previous) (diff)

by Peter Suter, 12 years ago

Adds col and template parameters to list format

comment:2 by Peter Suter, 12 years ago

Milestone: 0.12.4

The proposed format=clist seems to be the same as format=list, but instead of always displaying the summary, the col parameter is processed and e.g. $reporter | $summary is displayed with col=reporter|summary.

It seems to me this could just be added to the list format instead of a new clist format, as in the attached patch.

There I also try a similar idea, adding a template parameter so [[TicketQuery(id=10633, format=list, template=In $milestone: $summary (by $reporter))]] looks something like this: #10633 In 0.12.4: TicketQuery 'clist' format (by branson@…)

Hm, email obfuscation is actually not done yet.

Maybe a Genshi template would be more appropriate?

Do you think processing col would still be needed (in a non-table format) if there was template support?

Last edited 12 years ago by Peter Suter (previous) (diff)

comment:3 by Christian Boos, 12 years ago

Milestone: next-major-0.1X

Good idea!

Also, instead of a template parameter (or as an alternative to it), we could also try to use the block syntax:

{{{#!TicketQuery id=10633 format=list
In $milestone: $summary (by $reporter)

But using a Genshi template for that would be a security hazard (arbitrary code execution).

comment:4 by Peter Suter, 12 years ago

Would it make sense to create a helper function trac.ticket.web_ui.render_field() with some of the rendering logic from _prepare_fields and use that here? (And maybe in other places? For query results perhaps?)

comment:5 by Peter Suter, 6 years ago

In #12156 a ITicketQueryRenderer interface was proposed that might allow implementing the initial idea as a plugin.

Modify Ticket

Change Properties
Set your email in Preferences
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.