| 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 |
ReCreated by: merrillbeth@gmail.com |
|---|
| 17 |
Based on: TicketBox |
|---|
| 18 |
|
|---|
| 19 |
""" |
|---|
| 20 |
|
|---|
| 21 |
## NOTE: CSS2 defines 'max-width' but it seems that only few browser |
|---|
| 22 |
## support it. So I use 'width'. Any idea? |
|---|
| 23 |
|
|---|
| 24 |
import re |
|---|
| 25 |
import string |
|---|
| 26 |
|
|---|
| 27 |
## default style values |
|---|
| 28 |
styles = { "background": "#", |
|---|
| 29 |
"width": "60%", |
|---|
| 30 |
} |
|---|
| 31 |
from trac.wiki.macros import WikiMacroBase |
|---|
| 32 |
from trac.core import * |
|---|
| 33 |
|
|---|
| 34 |
__all__ = ['RoadmapBoxMacro'] |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
class RoadmapBoxMacro(WikiMacroBase): |
|---|
| 38 |
""" |
|---|
| 39 |
Demo macro for a greeting with an argument. |
|---|
| 40 |
{{{ |
|---|
| 41 |
[[RoadmapBox(args)]] |
|---|
| 42 |
}}} |
|---|
| 43 |
""" |
|---|
| 44 |
def expand_macro(self, formatter, name, args): |
|---|
| 45 |
tasklist=[] |
|---|
| 46 |
ticketlist = [] |
|---|
| 47 |
db = self.env.get_db_cnx() |
|---|
| 48 |
curs = db.cursor() |
|---|
| 49 |
txt=args |
|---|
| 50 |
option = {} |
|---|
| 51 |
option['milestone'] = txt |
|---|
| 52 |
try: |
|---|
| 53 |
curs.execute("SELECT id, summary, resolution, owner, status FROM ticket WHERE type ='task' and milestone='%s'" %(option['milestone'])+ "order by status") |
|---|
| 54 |
rows = curs.fetchall() |
|---|
| 55 |
for row in rows: |
|---|
| 56 |
if row[2]: |
|---|
| 57 |
cn="closed ticket" |
|---|
| 58 |
tasklist.append('<tr><td>%s - <a class="%s" href="%s" title="%s">%s</a></td>'% (row[1], cn, self.env.href.ticket(row[0]), row[1], row[0])) |
|---|
| 59 |
tasklist.append("<td>"+row[2].__str__()+"</td>" +"<td>"+row[3].__str__()+"</td>"+"<td>"+row[4].__str__()+"</td></tr>") |
|---|
| 60 |
else: |
|---|
| 61 |
cn="new ticket" |
|---|
| 62 |
tasklist.append('<tr><td>%s - <a class="%s" href="%s" title="%s">%s</a></td>'% (row[1], cn, self.env.href.ticket(row[0]), row[1], row[0])) |
|---|
| 63 |
tasklist.append("<td>"+row[2].__str__()+"</td>" +"<td>"+row[3].__str__()+"</td>"+"<td>"+row[4].__str__()+"</td></tr>") |
|---|
| 64 |
except Exception, e: |
|---|
| 65 |
return 'error: %s %s' % (Exception, e) |
|---|
| 66 |
|
|---|
| 67 |
try: |
|---|
| 68 |
curs.execute("SELECT id, summary, resolution, owner, status FROM ticket WHERE type ='defect' and milestone='%s'" %(option['milestone'])+ "order by status") |
|---|
| 69 |
rows = curs.fetchall() |
|---|
| 70 |
for row in rows: |
|---|
| 71 |
if row[2]: |
|---|
| 72 |
cn="closed ticket" |
|---|
| 73 |
ticketlist.append('<tr><td>%s - <a class="%s" href="%s" title="%s">%s</a></td>'% (row[1], cn, self.env.href.ticket(row[0]), row[1], row[0])) |
|---|
| 74 |
ticketlist.append("<td>"+row[2].__str__()+"</td>" +"<td>"+row[3].__str__()+"</td>"+"<td>"+row[4].__str__()+"</td></tr>") |
|---|
| 75 |
else: |
|---|
| 76 |
cn="new ticket" |
|---|
| 77 |
ticketlist.append('<tr><td>%s - <a class="%s" href="%s" title="%s">%s</a></td>'% (row[1], cn, self.env.href.ticket(row[0]), row[1], row[0])) |
|---|
| 78 |
ticketlist.append("<td>"+row[2].__str__()+"</td>" +"<td>"+row[3].__str__()+"</td>"+"<td>"+row[4].__str__()+"</td></tr>") |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
except Exception, e: |
|---|
| 82 |
return 'error: %s %s' % (Exception, e) |
|---|
| 83 |
taskString='' |
|---|
| 84 |
ticketString='' |
|---|
| 85 |
for task in tasklist: |
|---|
| 86 |
taskString=taskString+ (task) |
|---|
| 87 |
for ticket in ticketlist: |
|---|
| 88 |
ticketString=ticketString+(ticket) |
|---|
| 89 |
return ''' |
|---|
| 90 |
<table class="wiki" style="background: #f7f7f66; width:60%%;"> |
|---|
| 91 |
<fieldset class="ticketbox" style="background: #f7f7f0; width:80%%;"> |
|---|
| 92 |
<tr><td><strong>tasks associated with this milestone:</strong></td><td><strong>Resolution</strong></td><td><strong>Owner</strong></td><td><strong>Status</strong></td></tr>''' +taskString +'''</table> |
|---|
| 93 |
<table class="wiki" style="background: #f7f7f66; width:60%%;"> |
|---|
| 94 |
<fieldset class="ticketbox" style="background: #f7f7f0; width:80%%;"> |
|---|
| 95 |
<tr><td><strong>tickets associated with this milestone:</strong></td><td><strong>Resolution</strong></td><td><strong>Owner</strong></td><td><strong>Status</strong></td></tr>''' +ticketString +'''</table> |
|---|
| 96 |
''' |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|