Edgewall Software

Ticket #3259: ticket-timeline-comments.2.diff

File ticket-timeline-comments.2.diff, 2.4 KB (added by athomas, 6 years ago)

Preliminary patch for linking directly to ticket comments from timeline

  • trac/ticket/web_ui.py

     
    328328                      'closed': ('closedticket', 'closed'), 
    329329                      'edit': ('editedticket', 'updated')} 
    330330 
    331         def produce((id, t, author, type, summary), status, fields, comment): 
     331        def produce((id, t, author, type, summary), status, fields, comment, cid): 
    332332            if status == 'edit': 
    333333                if 'ticket_details' in filters: 
    334334                    info = '' 
     
    352352            href = format == 'rss' and req.abs_href.ticket(id) or \ 
    353353                                       req.href.ticket(id) 
    354354 
     355            if cid: 
     356                cid = cid.split('.')[-1] 
     357                href += '#comment:' + cid 
     358 
    355359            if status == 'new': 
    356360                message = summary 
    357361            else: 
     
    381385            for id,t,author,type,summary,field,oldvalue,newvalue in cursor: 
    382386                if not previous_update or (id,t,author) != previous_update[:3]: 
    383387                    if previous_update: 
    384                         ev = produce(previous_update, status, fields, comment) 
     388                        ev = produce(previous_update, status, fields, comment, cid) 
    385389                        if ev: 
    386390                            yield ev 
    387391                    status, fields, comment = 'edit', {}, '' 
    388392                    previous_update = (id,t,author, type, summary) 
    389393                if field == 'comment': 
     394                    cid = oldvalue 
    390395                    comment = newvalue 
    391396                elif field == 'status' and newvalue in ('reopened', 'closed'): 
    392397                    status = newvalue 
    393398                else: 
    394399                    fields[field] = newvalue 
    395400            if previous_update: 
    396                 ev = produce(previous_update, status, fields, comment) 
     401                ev = produce(previous_update, status, fields, comment, cid) 
    397402                if ev: 
    398403                    yield ev 
    399404             
     
    403408                               "  FROM ticket WHERE time>=%s AND time<=%s", 
    404409                               (start, stop)) 
    405410                for row in cursor: 
    406                     yield produce(row, 'new', {}, None) 
     411                    yield produce(row, 'new', {}, None, None) 
    407412 
    408413    # Internal methods 
    409414