Re: Silent submit for issue.item.html

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
Hi Tom:

In message
<DM6PR08MB47788B50E4C02B5347C14B0DCA7F0@DM6PR08MB4778.namprd08.prod.
outlook.com>, Tom Ekberg writes:
>I have a request from one of our tracker users to have 2 types of
>submit buttons for issue creation or editing. One submit button would
>write to the database (messages too) and do nothing else
>(silent). The other would work as it does now, writing to the
>database and sending emails using the nosy list. I don't see an easy
>way to do that other than have javascript that sets a field (input
>type="hidden") to a value that the detector nosyreaction.py can
>check.
>
>This seems like a hack. Is there a more elegant way to implement a
>"silent" submit button?

The nosy email is sent by a reactor. I don't know how to get the web
interface field to be visible to a reactor or auditor. There is a db
handle passed to the detectors, but I am not 100% sure it is the same
db handle that actions have via self.db. If it is, in theory you could
add:

	if @suppress_nosy in self.form:
	  self.db.webparam['@suppress_nosy'] = self.form['@suppress_nosy']

in the action handler for the edit action (usually EditAction in
roundup/cgi/actions.py) and then check the value of
db.webparam['@suppress_nosy]' in the reactor (or other detector).

You can wrap EditAction using a file in your extensions directory.

  class Edit2Action(EditItemAction):
    def handle(self):
	if @suppress_nosy in self.form:
	  self.db.webparam['@suppress_nosy'] = self.form['@suppress_nosy']
    
    	EditItemAction.handle(self)
	    
  def init(instance):
    '''Override the default edit action with this new version'''
    instance.registerAction('edit', Edit2Action)
	
to populate the webparam dict without having to rewrite EditAction.

IIRC, the db handle/object is created new on every transaction, it
should be safe to add new data to it (i.e. the form values shouldn't
leak into other transactions). I believe this is true as db.tx_Source
is transaction specific and I think visible to Actions.

However the value of self.db.webparam['@suppress_nosy'] isn't recorded
anywhere, so you will want logging to help debugging.

If you dislike requiring javascript, I think you can do something
like:

  self.db.webparam[@suppress_nosy] =
       self.form["submit"].value == "Quiet Submission"

along with

  <input type="submit" value="Quiet Submission">

(you may need to handle the encoding of the space in the value).

This should allow you to skip javascript entirely and use the submit
value to determine what option the user selected.

YMMV, I may have this wrong but I think this is how I considered doing
something similar.

I went a different way in my sysadmin tracker. I have three types of
messages. If the type is data, it suppresses notifications. There is a
type field on the message that is stored in the database and the nosy
reactor only triggers if the value is not data. The value is recorded
in the database along with the message and changes to the value are
recorded in the history log. It also doesn't require javascript as the
message type is just another dropdown to select the property value.

You can see an more extensive example of supplementing the EditItem
action in my tracker's repo:

  https://rouilj.dynamic-dns.net/fossil/roundup_sysadmin/artifact/a73e2c8ea9bad7ce

Also you can see the three types of messages at the tracker demo:

  https://rouilj.dynamic-dns.net/demo


Note https://rouilj.dynamic-dns.net/ is offline at the moment as
dynamic-dns seems to be having issues with resolution.

Have a great weekend and let us know how you implemented this.
--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
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.