Roundup Tracker

This code was ported to work with roundup 1.x and works with 1.5 at least. It has three parts:

  1. Redefinition for the @notes/:notes field in the issue.item template.
  2. Utility function that formats the message being replied to.
  3. Link to add to a msg display that will trigger the utility function by passing the message id as a url parameter.

Add tal similar to the below to define the @note textarea in your issue.item update form:

<textarea tal:condition="python:request.form.has_key('replyto') and
                                       not request.form.has_key('@note')"
     tal:content="python:utils.generateQuotedReply(db,request.form['replyto'].value)"
                        name="@note" wrap="hard" rows="20" cols="80"> </textarea>
<textarea tal:condition="python:not                            request.form.has_key('replyto')"
                        tal:content="request/form/@note/value | default"
                        name="@note" wrap="hard" rows="20" cols="80"></textarea>

This will allow a reply only if there is no note already defined (so it doesn't clobber an exiting note).

The function generateQuotedReply should be added to a .py file in the extensions directory of the tracker and consist of:

def generateQuotedReply(db, msgid):
    ''' Called with a message id it generates quoted text
    '''
    msgdb = db._db.msg
    userdb = db._db.user
    authorid = msgdb.get(msgid, 'author')
    if __debug__:
        print "message authorid: %s username: %s"%(authorid, userdb.get(authorid, 'username'))
    realname = userdb.get(authorid, 'realname')
    username = userdb.get(authorid, 'username')
    if realname is None:
        if username is None :
            name = "unknown author"
        else:
            name = username.replace("@", " at ")
    else:
        name = "%s (user%s)"%(realname, authorid)

    message = "In message msg%s on %s, %s said:\n>"%(msgid,
                    msgdb.get(msgid, 'date'), name) +  \
                    msgdb.get(msgid, 'content').replace("\n","\n>")
    if __debug__:
        print "message is: ", message
    return message

# then add the register call to the init for the module
def init(instance):
    instance.registerUtil('generateQuotedReply', generateQuotedReply)

(Note copy this from the raw view, indenting in python is important and gets messed up by the wiki.)

Add the following bit of tal for each message that gets displayed:

<div tal:condition="context/is_edit_ok">
  <a tal:attributes="href string:issue${context/id}?replyto=${msg/id}#changenote">reply to</a>
</div>