Ticket #890: Timeline.py.diff
| File Timeline.py.diff, 4.4 KB (added by Arthur.Ward@…, 4 years ago) |
|---|
-
trac/Timeline.py
old new 34 34 template_name = 'timeline.cs' 35 35 template_rss_name = 'timeline_rss.cs' 36 36 37 def get_info (self, start, stop, maxrows, tickets, 37 def get_info (self, start, stop, maxrows, tickets, ticket_comments, 38 38 changeset, wiki, milestone): 39 39 cursor = self.db.cursor () 40 40 41 41 tickets = tickets and self.perm.has_permission(perm.TICKET_VIEW) 42 ticket_comments = ticket_comments and self.perm.has_permission(perm.TICKET_VIEW) 42 43 changeset = changeset and self.perm.has_permission(perm.CHANGESET_VIEW) 43 44 wiki = wiki and self.perm.has_permission(perm.WIKI_VIEW) 44 45 milestone = milestone and self.perm.has_permission(perm.MILESTONE_VIEW) … … 52 53 REOPENED_TICKET = 4 53 54 WIKI = 5 54 55 MILESTONE = 6 56 TICKET_COMMENT = 7 55 57 56 58 q = [] 57 59 if changeset: … … 90 92 "name AS message, '' AS author " 91 93 "FROM milestone WHERE time>=%s AND time<=%s" % 92 94 (start, stop)) 95 if ticket_comments: 96 q.append("SELECT time, ticket AS idata, '' AS tdata, 7 AS type, " 97 "newvalue AS message, author AS author " 98 "FROM ticket_change WHERE field = 'comment' " 99 "AND time>=%s AND time<=%s" % (start, stop)) 93 100 94 101 q_str = string.join(q, ' UNION ALL ') 95 102 q_str += ' ORDER BY time DESC' … … 100 107 101 108 # Make the data more HDF-friendly 102 109 info = [] 110 tickets = {} 103 111 while 1: 104 112 row = cursor.fetchone() 105 113 if not row: … … 168 176 elif item['type'] == MILESTONE: 169 177 item['href'] = util.escape(self.env.href.milestone(item['message'])) 170 178 item['message'] = util.escape(item['message']) 171 else: # TICKET179 else: # all the TICKET types 172 180 item['href'] = util.escape(self.env.href.ticket(item['idata'])) 181 if item['type'] == TICKET_COMMENT: 182 # The following would be ok if there would be a cost effective way 183 # to get that change nunmber... 184 # item['href'] += '#change_%d' % item['change'] 185 pass 186 else: 187 tickets[(item['idata'], item['time'])] = 1 173 188 msg = item['message'] 174 189 item['shortmsg'] = util.escape(util.shorten_line(msg)) 175 190 item['message'] = wiki_to_oneliner( … … 187 202 item['message.rss'] = util.escape(item['message'] or '') 188 203 189 204 info.append(item) 190 return info 205 # Ok, the following line is maybe not Python 2.1 friendly, I don't know... 206 # return [ i for i in info if i['type'] != 7 or not tickets.has_key((i['idata'], i['time'])) ] 207 info2 = [] 208 for item in info: 209 if item['type'] != 7 or not tickets.has_key((item['idata'], item['time'])): 210 info2.append(item) 211 return info2 191 212 192 213 def render (self): 193 214 self.perm.assert_permission(perm.TIMELINE_VIEW) … … 218 239 219 240 wiki = self.args.has_key('wiki') 220 241 ticket = self.args.has_key('ticket') 242 ticket_comments = self.args.has_key('ticket_comments') 221 243 changeset = self.args.has_key('changeset') 222 244 milestone = self.args.has_key('milestone') 223 245 if not (wiki or ticket or changeset or milestone): … … 227 249 self.req.hdf.setValue('timeline.wiki', 'checked') 228 250 if ticket: 229 251 self.req.hdf.setValue('timeline.ticket', 'checked') 252 if ticket_comments: 253 self.req.hdf.setValue('timeline.ticket_comments', 'checked') 230 254 if changeset: 231 255 self.req.hdf.setValue('timeline.changeset', 'checked') 232 256 if milestone: … … 247 271 '?daysback=90&max=50%s&format=rss' % rssargs, 248 272 'RSS Feed', 'application/rss+xml', 'rss') 249 273 250 info = self.get_info (start, stop, maxrows, ticket, 274 info = self.get_info (start, stop, maxrows, ticket, ticket_comments, 251 275 changeset, wiki, milestone) 252 276 util.add_dictlist_to_hdf(info, self.req.hdf, 'timeline.items') 253 277 self.req.hdf.setValue('title', 'Timeline')
