TicketBoxMacro: summary_inline.patch
| File summary_inline.patch, 3.1 kB (added by laas@eenet.ee, 1 year ago) |
|---|
-
TicketBox.py
old new 38 38 "background": "#f7f7f0", 39 39 "width": "25%", 40 40 } 41 inline_styles = { 42 "background": "#f7f7f0", 43 } 41 44 42 45 args_pat = [r"#?(?P<tktnum>\d+)", 43 46 r"{(?P<rptnum>\d+)}", 44 47 r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 45 48 r"(?P<width>\d+(pt|px|%))", 49 r"(?P<summary>summary)", 50 r"(?P<inline>inline)", 46 51 r"(?P<title1>'.*')", 47 52 r'(?P<title2>".*")'] 48 53 … … 61 66 if not txt: 62 67 txt = '' 63 68 items = [] 69 long_items = {} 70 show_summary = False 71 inline = False 64 72 title = "Tickets" 65 73 args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 66 74 for arg in [string.strip(s) for s in txt.split(',')]: … … 76 84 styles['width'] = match.group('width') 77 85 elif match.group('tktnum'): 78 86 items.append(int(match.group('tktnum'))) 87 elif match.group('summary'): 88 show_summary = True 89 elif match.group('inline'): 90 inline = True 79 91 elif match.group('rptnum') or match.group('rptnum2'): 80 92 num = match.group('rptnum') or match.group('rptnum2') 81 93 dv = {} … … 103 115 if rows: 104 116 descriptions = [desc[0] for desc in curs.description] 105 117 idx = descriptions.index('ticket') 118 summ = descriptions.index('summary') 106 119 for row in rows: 107 120 items.append(row[idx]) 121 long_items[row[idx]] = row[summ] 108 122 finally: 109 123 if not hasattr(env, 'get_cnx_pool'): 110 124 # without db connection pool, we should close db. … … 116 130 try: 117 131 # for trac 0.9 or later 118 132 from trac.wiki.formatter import wiki_to_oneliner 119 html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "),120 env, env.get_db_cnx())121 133 except: 122 134 # for trac 0.8.x 123 135 from trac.WikiFormatter import wiki_to_oneliner 136 137 if show_summary: 138 html = string.join([wiki_to_oneliner("%s (#%d)" % (v,k), 139 env, env.get_db_cnx()) for k,v in long_items.iteritems()], "<br>") 140 else: 124 141 html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 125 hdf, env, env.get_db_cnx()) 142 env, env.get_db_cnx()) 143 126 144 if html != '': 127 145 try: 128 146 title = title % len(items) # process %d in title 129 147 except: 130 148 pass 131 style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 149 if inline: 150 style = string.join(["%s:%s" % (k,v) for k,v in inline_styles.items() if v <> ""], "; ") 151 else: 152 style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 132 153 return '<fieldset class="ticketbox" style="%s"><legend>%s</legend>%s</fieldset>' % \ 133 154 (style, title, html) 134 155 else:
