root/roadmapboxmacro/RoadmapBox.py

Revision 1331, 1.6 kB (checked in by frido, 2 years ago)

RoadmapBoxMacro:

coderanger says to use env.href.ticket, and he's probably right

Line 
1 """
2
3 Display a box with tickets concercing a certain Milestone AND Keyword.
4 We use tagging to group certain keywords together based on featureset,
5 since they might fall in different components. This is ideal in the
6 Roadmap display, since it shows nice summary boxes of all open/closed
7 tickets by keyword.
8
9 Syntax:
10
11 [[RoadmapBox(keyword:Quickies;milestone:02-corecleanup)]]
12 [[RoadmapBox(keyword:Bugfixes;milestone:02-corecleanup)]]
13 [[RoadmapBox(keyword:Other;milestone:02-corecleanup)]]
14
15 Created by: frido.ferdinand@gmail.com
16 Based on: TicketBox
17
18 """
19
20 ## NOTE: CSS2 defines 'max-width' but it seems that only few browser
21 ##       support it. So I use 'width'. Any idea?
22
23 import re
24 import string
25
26 ## default style values
27 styles = { "background": "#",
28            "width": "60%",
29            }
30
31 def execute(hdf, txt, env):
32         db = env.get_db_cnx()
33         curs = db.cursor()
34         option = {}
35         for args in txt.split(";"):
36                 (key, val) = args.split(":")
37                 option[key] = val
38         ul = []
39         try:
40                 curs.execute("SELECT id, summary, resolution FROM ticket WHERE milestone='%s' AND keywords='%s'" % (option["milestone"], option["keyword"]))
41                 rows = curs.fetchall()
42                 for row in rows:
43                         if row[2]:
44                                 cn="closed ticket"
45                         else:
46                                 cn="new ticket"
47                         ul.append('<li>%s - <a class="%s" href="%s" title="%s">%s</a></li>' % (row[1], cn, env.href.ticket(row[0]), row[1], row[0]))
48         except Exception, e:
49                 return 'error: %s %s' % (Exception, e)
50         return '''
51 <fieldset class="ticketbox" style="background: #f7f7f0; width:80%%;">
52         <legend>%s:</legend>
53         <ul>
54         %s
55         </ul>
56 </fieldset>
57 ''' % (option["keyword"], "\n".join(ul))
Note: See TracBrowser for help on using the browser.