Re: Checking for empty change note on issue creation
"David Hancock" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
This is great information, exactly what I needed, and db.getuid() is a much smarter way. I was backing into getting a name into a newreaction email by trying to force an initial change note, but getting the uid and the realname is much simpler. Thank you! -- David Hancock [email protected] On Tue, Feb 4, 2020, at 8:41 PM, John Rouillard wrote: > 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