public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
From: "Andrew Kemp" <Andrew.Kemp@wolfsonmicro.com>
To: <help-gnats@gnu.org>
Subject: RE: Adding "Approval" Mechanism
Date: Thu, 25 Nov 2004 17:22:00 -0000	[thread overview]
Message-ID: <EC5CF42A8A0AC548B1E44A70157A628B5163FE@orlando.wolfsonmicro.main> (raw)

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

Hi,

I have cobbled something into gnatsweb to support an approval system
through emails. Firstly I edited the dbconfig file fairly heavily so
that gnatsweb sends HTML emails. The main mail that is sent out is
whenever there is an audit trail change.

In our local Gnats DB we have a state "awaiting-approval" as well as
"approved" and a few other new ones. For each possible state I create a
separate DIV in the HTML mail and use inline CSS style to say which one
is displayed. This is controlled with CSS lines in the dbconfig like

   div { display: none }\n\
   div.%s { display: inline }\n\

and the format element used is 'State'.

In the "awaiting-approval" state, the mail contains two big buttons for
Accept / Reject which the originator can click on. This uses an
additional field in the Gnats link to bypass the normal login and use an
account which has edit access. This required a small hack to
gnatsweb.pl.

The link I use is

h**p://someserver/cgi-bin/gnats/gnatsweb.pl/1?submittype=mail&pr=%s&cmd=
submit edit&State=approved&database=default&State-Changed-Why=%s
email_approval

It is the "submittype=mail" field that I use to bypass the login. I know
that this provides a potential edit backdoor, but Gnats security is not
great anyway and I trust my users who are all local :-)


Cheesey, but it works!

Andy.

I have attached my dbconfig if you want to see what I have done. You
will have to add your own images.

[-- Attachment #2: dbconfig --]
[-- Type: application/octet-stream, Size: 9436 bytes --]

#
# This message is used when mailing an initial response back to the 
# PR submitter.
#

mail-format "initial-response-to-submitter" {
    from-address {
	fixed-address "gnats-admin"
    }

    # For addresses that are joined with |, we try each one in turn, from
    # left to right,  until we find one that's non-empty.
    # Multiple addresses may be listed here.
    to-addresses {
	"Reply-To:" | "From:" | "From" | "Submitter-Id"
    }

    header {
	format "Subject: GNATS: Re: %s/%s: %s\n\
Content-Type: text/html;\n"

	fields { "Category" "Number" "Subject:" }
    }

    body {
format "\
\
\
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n\
\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n\
\n\
<HTML>\n\
 <head>\n\
  <title>PR submission notification PR/%s</title>\n\
  <STYLE type=\"text/css\">\n\
    body {background-color: #d0e0ff;font: 10pt sans-serif;margin: 2px 4ex 2px 4ex;border: 3px solid #7010a0;padding: 1.5ex;color: black }\n\
    h1 {color: white;padding: 1ex;display: block;background-color: #0077b3;border: outset #b0c0e0;font-size: 14pt }\n\
    a {color: #0077b3}\n\
    a:hover {color: #7010a0;}\n\
    pre {font-size: 10pt }\n\
  </STYLE>\n\
 </head>\n\
\
<body>\n\
<H1>PR submission notification PR/%s</H1>\n\
\n\
<PRE>\n\
Thank you very much for your problem report.\n\
It has the internal identification `%s/%s'.\n\
The individual assigned to look at your\n\
report is: <B>%s</B>. \n\
\n\
You can view the status of this report by following the link \n\
\n\
</PRE><A HREF=\"http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=view&pr=%s\">\n\
<PRE>http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=view&pr=%s</A>\n\
\n\
%F%F%F%F\n\
</PRE>\n\
</body>\n\
</html>\n\
"
	fields { "Number" "Number" "Category" "Number" "Responsible[fullname]" "Number"
	         "Number" "Category" "Responsible" "Synopsis" "Arrival-Date" }
    }
}

#
# The message sent to the responsible parties when a new non-pending
# PR arrives.
#

mail-format "initial-pr-notification" {
    # Who the mail is from.
    from-address {
	"From:" | "From"
    }

    # We send mail to the responsible person, the addresses listed in
    # the contact and notify fields of the submitter adm file entry for
    # the Submitter-Id, and the notify person listed in the category
    # adm file.
    to-addresses {
	"Responsible"
	"Submitter-Id[contact]"
	"Submitter-Id[notify]"
	"Category[notify]"
    }

    # The reply-to address; either use the Reply-To: or From: header values 
    # from the PR, or the Submitter-Id's mail address.
    reply-to {
	"Reply-To:" | "From:" | "Submitter-Id"
    }

    # Any additional header text we want to add.  Must have a newline at the
    # end of each line.
    header {
	format "Subject: GNATS: %s/%s: %s\nCc: %s\n\
Content-Type: text/html;\n"
	fields { "Category" "Number" "Subject:" "Notify-List" }
    }

    body {
format "\
\
\
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n\
\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n\
\n\
<HTML>\n\
 <head>\n\
  <title>PR submission notification PR/%s</title>\n\
  <STYLE type=\"text/css\">\n\
    body {background-color: #d0e0ff;font: 10pt sans-serif;margin: 2px 4ex 2px 4ex;border: 3px solid #7010a0;padding: 1.5ex;color: black }\n\
    h1 {color: white;padding: 1ex;display: block;background-color: #0077b3;border: outset #b0c0e0;font-size: 14pt }\n\
    a {color: #0077b3}\n\
    a:hover {color: #7010a0;}\n\
    pre {font-size: 10pt }\n\
  </STYLE>\n\
 </head>\n\
\
<body>\n\
<H1>PR submission notification PR/%s</H1>\n\
\n\
<PRE>\n\
The following PR has been submitted by <B>%s</B>.\n\
It has the internal identification `%s/%s'.\n\
\n\
You can view the status of this report by following the link \n\
\n\
</PRE><A HREF=\"http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=view&pr=%s\">\n\
<PRE>http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=view&pr=%s</A>\n\
\n\
Or you can edit it with this link \n\
\n\
</PRE><A HREF=\"http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=edit&pr=%s\">\n\
<PRE>http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=edit&pr=%s</A>\n\
\n\
%F%F%F%F\n\
</PRE>\n\
</body>\n\
</html>\n\
"
	fields { "Number" "Number" "Originator" "Category" "Number" "Number" "Number" "Number"
	         "Number" "Category" "Responsible" "Synopsis" "Arrival-Date" }
    }
}

#
# This format is used for initial PRs that end up as pending PRs.
#
mail-format "initial-pr-notification-pending" {
    #
    # Is this good?
    #
    from-address {
	"From:" | "From"
    }

    #
    # Boring--we only tell gnats-admin about it.
    #
    to-addresses {
	fixed-address "gnats-admin"
    }

    #
    # Questionable for a pending PR.
    #
    reply-to {
	"Reply-To:" | "From:" | "Submitter-Id"
    }

    header {
	format "Subject: GNATS: %s/%s: %s (pending)\nCc: %s\n"
	fields { "Category" "Number" "Subject:" "Notify-List" }
    }

    body {
#
#       See above.
#
#	($ExpireTime != "") {
#		format "\tThe contract type is `%s' with a response time of %d business hours.\n"
#		fields { "Submitter-Id[type]" "$ExpireTime" }
#	}
	format "%P"
	fields { "$" }
    }
}

#
# Used when a response to a PR is received via email.
#
# The following parameters are passed in:
# $MailFrom -- the From: line of the original message
# $MailTo -- the To: line of the original message
# $MailSubject: The Subject: line of the original message
# $MailCC: The CC: line of the original message
# $NewAuditTrail -- the text of the new audit trail entry (the body of
#	            the message)
#
mail-format "appended-email-response" {
    from-address {
	"$MailFrom"
    }

    #
    # Should we send a copy to the user that sent in the message?
    #
    to-addresses {
	"Responsible"
	"Submitter-Id[contact]"
    }

    reply-to {
	"$MailFrom"
    }

    header {
	format "Subject: GNATS: %s/%s: %s\n"
	fields { "Category" "Number" "$MailSubject" }
    }

    body {
	format "The following reply was made to PR %s/%s; it has been noted by GNATS.\n\n%s"
	fields { "Category" "Number" "$NewAuditTrail" }
    }
}

#
# Used to send mail for a change that generates an Audit-Trail entry.
# The following parameters are available:
# $EditUserEmailAddr -- the email address of the user editing the PR
# $OldResponsible -- the previous Responsible field entry, if it was changed
# $NewAuditTrail -- the Audit-Trail: entries that have been appended
#		    by the edits
#
# AKK
mail-format "audit-mail" {
    from-address {
	"$EditUserEmailAddr"
    }

    #
    to-addresses {
	"Responsible"
	"$OldResponsible"
	"Category[notify]"
	"Submitter-Id[contact]"
	"$EditUserEmailAddr"
	"Reply-To:" | "From:" | "From"
    }

    #
    # ???  Good question!
    #
    #reply-to {
#	fixed-address "bugs"
#    }

    header {
	format "Subject: GNATS: Re: %s/%s\nCc: %s\n\
Content-Type: text/html;\n"
	fields { "Category" "Number" "Notify-List" }
    }

    body {
format "\
\
\
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n\
\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n\
\n\
<HTML>\n\
 <head>\n\
  <title>PR status change PR/%s</title>\n\
  <STYLE type=\"text/css\">\n\
    div { display: none }\n\
    div.%s { display: inline }\n\
    body {background-color: #d0e0ff;font: 10pt sans-serif;margin: 2px 4ex 2px 4ex;border: 3px solid #7010a0;padding: 1.5ex;color: black }\n\
    h1 {color: white;padding: 1ex;display: block;background-color: #0077b3;border: outset #b0c0e0;font-size: 14pt }\n\
    a {color: #0077b3}\n\
    a:hover {color: #7010a0;}\n\
    pre {font-size: 10pt }\n\
  </STYLE>\n\
 </head>\n\
\
<body>\n\
<H1>PR status change PR/%s</H1>\n\
\n\
<PRE>\n\
The PR submitted by %s regarding <B>%s</B> has had its status modified.\n\
\n\
\
</PRE>\n\
<DIV id=\"feedback\" class=\"feedback\">\n\
<P><B>%s has updated this PR and is awaiting feedback -  details on the link below<BR>\n\
<FONT COLOR=\"#ff4444\" SIZE=+1>Please can you give feedback on this call</B></FONT></P>\n\
</DIV>\n\
<PRE>\n\
\
\
\
\
</PRE>\n\
<DIV id=\"suspended\" class=\"suspended\">\n\
<P><B>%s has suspended this PR</B> - no further action is planned.</P>\n\
</DIV>\n\
<PRE>\n\
\
\
\
\
</PRE>\n\
<DIV id=\"approved\" class=\"approved\">\n\
<P><B>This PR has now been approved</B></P>\n\
</DIV>\n\
<PRE>\n\
\
\
\
\
You can view the details by following the link \n\
\n\
</PRE><A HREF=\"http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=view&pr=%s\">\n\
<PRE>http://www/cgi-bin/gnats/gnatsweb.pl?database=default&cmd=view&pr=%s</A>\n\
\n\n\
</PRE>\n\
\
\
\
\
<DIV id=\"awaiting-approval\" class=\"awaiting-approval\">\n\
Please test the modifications and then click <I>Approve</I> or <I>Reject</I><BR>\n\
<a href=\"http://www/cgi-bin/gnats/gnatsweb.pl/1?submittype=mail&pr=%s&cmd=submit edit&State=approved&database=default&State-Changed-Why=%s email_approval\">\n\
<IMG BORDER=0 SRC=\"http://www/Intranet/Gnats/icons/accept.jpg\" WIDTH=191 HEIGHT=88 ALT=\"Accept\"></a><BR>\n\
<a href=\"http://www/cgi-bin/gnats/gnatsweb.pl/1?submittype=mail&pr=%s&cmd=submit edit&State=feedback&database=default&State-Changed-Why=%s email_rejection\">\n\
<IMG BORDER=0 SRC=\"http://www/Intranet/Gnats/icons/reject.jpg\" WIDTH=181 HEIGHT=88 ALT=\"Reject\"></a><BR>\n\
</DIV>\n\
\
\
\
\
<PRE>\n\n\
%s\n\
</PRE>\n\
</body>\n\
</html>\n\
"
	fields { "Number" "State" "Number" "Originator" "Synopsis" "Responsible[fullname]" "Responsible[fullname]" "Number" "Number" "Number" "Originator" "Number" "Originator" "$NewAuditTrail" }
    }
}


[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnats

             reply	other threads:[~2004-11-25 17:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-25 17:22 Andrew Kemp [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-11-24 18:20 Pankaj Garg
2003-08-30  8:09 David S Gathright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EC5CF42A8A0AC548B1E44A70157A628B5163FE@orlando.wolfsonmicro.main \
    --to=andrew.kemp@wolfsonmicro.com \
    --cc=help-gnats@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).