Re: Checking for empty change note on issue creation

John Rouillard <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <CANfx4mvvLOvCDs6-63ib9DWtJAWkvAarbn3St-jvEFyhjNW9+Q@mail.gmail.com>
Hi David:

On Tue, Feb 4, 2020 at 11:36 AM David Hancock <[email protected]> wrote:
> I've been trying to add to the "new reaction" detector a check for a missing/empty change note. It seems like
> what I need is to import Reject and then Reject the creation with an error message, but it looks like Reject only
> works in an auditor, not a reactor.

Correct, only an auditor can reject a change. By the time the reactor
fires, the data/transaction has been committed
to the database. So there is no sense in raising Reject.

> It's a bit of a chicken-and-egg problem -- we currently accept the empty change note but without it, there's no message
> from which we can get the author id.

If you want the id of the person committing the change, you should be
able to get this in an auditor or detector by calling:

  db.getuid()

IIRC the user creating the transaction is always the author of the
message (if there is one). Search
http://roundup.sourceforge.net/docs/customizing.html for getuid and
you see this line:

    " Also, the current id of the current user is available as
db.getuid(). This isn’t so useful in templates (where you
      have request/user), but it can be useful in detectors or interfaces."

note that this is in the templates section, so not exactly obvious.

> I don't want to make change note required always -- just at the time of creation.
You can set up a 'create' auditor that requires a change note, while
the set auditor does not.
In the init function at the bottom of nosyreaction.py you should see:

    db.issue.audit('create', updatenosy)

so add a new line:

   db.issue.audit('create', musthavemessage)

then in the musthavemessage function:

def updatenosy(db, cl, nodeid, newvalues):

   ...
   if 'messages' not in newvalues:
       raise Reject('Issue creation must have a change note.')

From what you have said, I assume you have read:

  http://roundup.sourceforge.net/docs/customizing.html#detectors-adding-behaviour-to-your-tracker

Hopefully the above will give you what you want.

-- rouilj


_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.