| 37 | | Save this to a file (tm.py) and place in your plugins/wiki-macros directory, just as you would do with other old style macros |
|---|
| 38 | | |
|---|
| 39 | | {{{ |
|---|
| 40 | | """ |
|---|
| 41 | | Lists ticket and milestone information |
|---|
| 42 | | |
|---|
| 43 | | This macro takes one parameter, the ticket id |
|---|
| 44 | | """ |
|---|
| 45 | | |
|---|
| 46 | | from StringIO import StringIO |
|---|
| 47 | | |
|---|
| 48 | | def execute(hdf, args, env): |
|---|
| 49 | | db = env.get_db_cnx() |
|---|
| 50 | | cursor = db.cursor() |
|---|
| 51 | | |
|---|
| 52 | | sql = "SELECT id, milestone FROM ticket WHERE id = '%s'" % args |
|---|
| 53 | | |
|---|
| 54 | | cursor.execute(sql) |
|---|
| 55 | | |
|---|
| 56 | | buf = StringIO() |
|---|
| 57 | | |
|---|
| 58 | | row = cursor.fetchone() |
|---|
| 59 | | if row == None: |
|---|
| 60 | | buf.write('Ticket with ID "%s" was not found' % args) |
|---|
| 61 | | else: |
|---|
| 62 | | 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])) |
|---|
| 63 | | |
|---|
| 64 | | return buf.getvalue() |
|---|
| 65 | | }}} |
|---|
| | 37 | You can check out TicketMilestoneDisplayMacro from [http://trac-hacks.org/svn/ticketmilestonedisplaymacro here] using Subversion, or [source:ticketmilestonedisplaymacro browse the source] with Trac. |
|---|