TicketMilestoneDisplayMacro: tm.py

File tm.py, 0.6 kB (added by fsbojason, 2 years ago)

Macro File

Line 
1 """
2 Lists all tickets matching a given regular expression
3
4 This macro takes one parameter, the regexp
5 """
6
7 import time
8 import re
9 from StringIO import StringIO
10
11 def execute(hdf, args, env):
12     db = env.get_db_cnx()
13     cursor = db.cursor()
14
15     sql = "SELECT id, milestone FROM ticket WHERE id = '%s'" % args
16
17     cursor.execute(sql)
18
19     buf = StringIO()
20
21     row = cursor.fetchone()
22     if row == None:
23       buf.write('Ticket with ID "%s" was not found' % args)
24     else:
25       buf.write('[<a href="%s">Ticket #%s</a>, <a href="%s">Milestone: %s</a>]' % (env.href.ticket(row[0]), row[0], env.href.milestone(row[1]), row[1]))
26    
27     return buf.getvalue()