Dear Peter,

The macro works and it is exactly what I needed!

Thank you very much! I have only recently started to dive into and maintain 
our Trac environment, it is a steep learning curve but I am getting there. 
You have now introduced me to a powerful way of customizing the wiki pages 
- I am going to get better acquainted with the macro's and plugins now, 
thank you for jumpstarting me on this track.

Regards,
Ino

On Thursday, June 21, 2012 7:28:58 PM UTC+2, Peter Suter wrote:
>
> Hi 
>
>  > In administration view, I get a table of all the versions and 
> > accompanying dates. 
> > Is there a way to include this table in a wiki page so that anyone can 
> > read it? 
> > A macroor query ... 
>
> The simplest way would probably be a "Ticket Report". Create a new 
> ticket report and write the following SQL query in the "Query for 
> Report" field: 
>
> SELECT * FROM version 
>
> If you prefer a macro, try this: 
>
> from genshi.builder import tag 
> from trac.wiki.macros import WikiMacroBase 
> from trac.ticket import model 
> from trac.util.datefmt import format_datetime 
>
> class ListVersionsMacro(WikiMacroBase): 
>      """List all versions and their dates. 
>      """ 
>
>      def expand_macro(self, formatter, name, content): 
>          versions = model.Version.select(self.env) 
>          return tag.table( 
>              tag.thead(tag.tr(tag.th("Version"), tag.th("Released"))), 
>              tag.tbody([tag.tr( 
>                  tag.td(version.name), 
>                  tag.td(version.time and format_datetime(version.time)) 
>              ) for version in versions]), class_="listing") 
>
> Hope this helps, 
> Peter 
>

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/trac-users/-/H2LKecTtlfsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.

Reply via email to