public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
* Re: Patch: Required fields on inital PR creation
       [not found] ` <200210161242.g9GCgjlU002272@pindari.platypuspartners.com>
@ 2002-10-26 10:42   ` Lars Henriksen
  2002-10-26 15:12     ` Yngve Svendsen
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Henriksen @ 2002-10-26 10:42 UTC (permalink / raw)
  To: Andrew Gray; +Cc: hatzis, help-gnats

On Wed, Oct 16, 2002 at 10:42:46PM +1000, Andrew Gray wrote:
> > Please review (and hopefully accept) the following patch that fixes a bug
> > in the 'on-change require' functionality and also expands the Gnats grammar
> > to allow for "required input fields" upon initial PR creation.
> 
> Thanks for submitting that patch. I will have a look at it in the next
> week and let you know if I have any questions.

The 'on-change require' is a very nice feature. Unfortunately it is only
documented in the code! A patch for the manual follows. 

Back in May, Mel Hatzis submitted another very nice patch, concerned with
subject line parsing:

http://mail.gnu.org/pipermail/help-gnats/2002-May/002930.html

Are you considering that one for inclusion?

Lars Henriksen

Index: p-admin.texi
===================================================================
RCS file: /cvsroot/gnats/gnats/doc/p-admin.texi,v
retrieving revision 1.28
diff -u -r1.28 p-admin.texi
--- p-admin.texi	24 Oct 2002 12:46:56 -0000	1.28
+++ p-admin.texi	26 Oct 2002 17:15:24 -0000
@@ -690,21 +690,19 @@
 The @code{on-change} subsection of a @code{fields} section specifies one
 or more actions to be performed when the field value is edited by the
 user.  It has the general form
+
 @example
 on-change [ "query-expression" ] @{
-@*
 @ @ [ add-audit-trail ]
-@*
 @ @ [ audit-trail-format @{
 @ @ @ @ format "formatstring"
 @ @ @ @ [ fields @{ "fieldname" ... @} ]
 @ @ @} ]
-@*
 @ @ [ require-change-reason ]
-@*
 @ @ [ set-field | append-to-field "fieldname" @{
 @ @ @ @ "format-string" [ fieldlist ]
 @ @ @} ]
+@ @ [ require @{ "fieldname" ... @} ]
 @}
 @end example
 
@@ -734,6 +732,14 @@
 @code{append-to-field} option (the @code{read-only} option on a field is
 ignored).  However, the changes are subject to the usual field content
 checks.
+
+The @code{require} option specifies that one or more fields must have
+a (non-blank) value when this field is changed.
+
+A field may be enforced to have a (non-blank) value at all times by
+including it in the set of fields required for the initial PR, see
+@ref{Initial PR input fields}, as well as in the set of fields required
+on change of the field itself.
 
 There is also a global @code{on-change} section that is executed once
 for each PR edit.  A typical use for such a section is to set the


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: Required fields on inital PR creation
  2002-10-26 10:42   ` Patch: Required fields on inital PR creation Lars Henriksen
@ 2002-10-26 15:12     ` Yngve Svendsen
  0 siblings, 0 replies; 6+ messages in thread
From: Yngve Svendsen @ 2002-10-26 15:12 UTC (permalink / raw)
  To: Lars Henriksen, Andrew Gray; +Cc: hatzis, help-gnats

At 19:25 26.10.2002 +0200, Lars Henriksen wrote:
>The 'on-change require' is a very nice feature. Unfortunately it is only
>documented in the code! A patch for the manual follows.

Applied. Actually, I had just noticed the omission in the manual and was 
just about to start fixing it myself.

Now, we need a way for clients to get the "initial-entry required" stuff 
from gnatsd. Gnatsweb should for instance be able to mark required fields 
on the Create PR page. I have cooked up a 20-liner that should take care of 
this, implementing "LIST InitialRequiredFields".

I need to test a tiny bit more, then I'll submit to help-gnats.

- Yngve




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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: Required fields on inital PR creation
       [not found] ` <5.2.0.5.0.20021026235808.00b43f80@ms-etro01-01.norway.sun. com>
@ 2002-10-27  3:16   ` Yngve Svendsen
  0 siblings, 0 replies; 6+ messages in thread
From: Yngve Svendsen @ 2002-10-27  3:16 UTC (permalink / raw)
  To: help-gnats

At 00:13 27.10.2002 +0200, Yngve Svendsen wrote:
>Now, we need a way for clients to get the "initial-entry required" stuff 
>from gnatsd. Gnatsweb should for instance be able to mark required fields 
>on the Create PR page. I have cooked up a 20-liner that should take care 
>of this, implementing "LIST InitialRequiredFields".

Here it comes. As I said, it implements an "InitialRequiredFields" argument 
for the gnatsd LIST command.

I need this in order to make marking of required fields work in Gnatsweb, 
so unless there are serious protests, I'll apply it tomorrow, also taking 
care of the associated docs.

- Yngve

Index: lists.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/lists.c,v
retrieving revision 1.19
diff -u -p -r1.19 lists.c
--- lists.c     4 Dec 2001 20:04:43 -0000       1.19
+++ lists.c     27 Oct 2002 11:10:12 -0000
@@ -37,6 +37,7 @@ struct list_type_list {
    { "States",             ListStates,             ".sta", "state" },
    { "FieldNames",         ListFieldNames,         ".fns", NULL },
    { "InitialInputFields", ListInitialInputFields, ".lfn", NULL },
+  { "InitialRequiredFields", ListInitialRequiredFields, ".lrn", NULL },
    { "Databases",          ListDatabases,          ".dbl", NULL },
    { NULL,                InvalidListType,        NULL,   NULL }
  };
@@ -142,6 +143,16 @@ getGnatsFile (const DatabaseInfo databas
           {
             FieldDef field = fieldDefForIndex (t->index);
             fprintf (fpout, "%s\n", field->name);
+         }
+       break;
+      }
+    case ListInitialRequiredFields:
+      {
+       FieldList fields = getRequiredInputFields(database);
+       while (fields != NULL)
+         {
+           fprintf (fpout, "%s\n", complexFieldIndexToString (fields->ent));
+           fields = fields->next;
           }
         break;
        }
Index: query.h
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/query.h,v
retrieving revision 1.36
diff -u -p -r1.36 query.h
--- query.h     10 Feb 2002 18:24:02 -0000      1.36
+++ query.h     27 Oct 2002 11:10:12 -0000
@@ -28,7 +28,8 @@ struct re_pattern_buffer;
  typedef enum e_lists {
    InvalidListType = -1,
    ListCategories = 0, ListSubmitters, ListResponsible, ListStates,
-  ListFieldNames,  ListInitialInputFields, ListDatabases
+  ListFieldNames,  ListInitialInputFields, ListInitialRequiredFields,
+  ListDatabases
  } ListTypes;

  /* The four operations to perform. */ 



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: Required fields on inital PR creation
       [not found] <3DACA802.3060904@juniper.net>
       [not found] ` <200210161242.g9GCgjlU002272@pindari.platypuspartners.com>
       [not found] ` <5.2.0.5.0.20021026235808.00b43f80@ms-etro01-01.norway.sun. com>
@ 2002-10-27 11:37 ` Yngve Svendsen
  2002-10-28 11:22   ` Mel Hatzis
  2 siblings, 1 reply; 6+ messages in thread
From: Yngve Svendsen @ 2002-10-27 11:37 UTC (permalink / raw)
  To: hatzis, help-gnats

At 16:42 15.10.2002 -0700, Mel Hatzis wrote:
>Please review (and hopefully accept) the following patch that fixes a bug
>in the 'on-change require' functionality and also expands the Gnats grammar
>to allow for "required input fields" upon initial PR creation.
>
>1/ The "require { fields }" functionality that's part of the on-change edit
>    options for a field is only doing a check for field_value == NULL 
> right now
>    (rather than also checking for empty strings). Since field values are
>    generally initialized to an empty string (upon creation), the 'require'
>    clause is basically useless. The patch adds a check for field_value == "".
>
>2/ It is extremely useful to allow the Gnats administrator to configure
>    Gnats so that a predefined set of fields must be assigned a value upon 
> initial
>    PR creation. Together with the field's own 'on-change require' clause, 
> this
>    allows for fields that can never have a null (blank) value.
>    Allowing the Gnats administrator to enforce non-null fields this way 
> provides
>    a powerful mechanism toward improved data integrity.

This doesn't work quite as it should with multitext fields. If a field is 
in the initial-entry fields list, both send-pr and Gnatsweb will include it 
when they submit PRs, even if it is empty. In the submitted PR text, these 
fields will contain newline character but nothing else. This slips past the 
require functionality that this patch implements.

I suggest we also check for space characters, as defined by isspace(), by 
making the following trivial change:

Index: edit.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/edit.c,v
retrieving revision 1.58
diff -u -p -r1.58 edit.c
--- edit.c      24 Oct 2002 12:45:09 -0000      1.58
+++ edit.c      27 Oct 2002 19:29:43 -0000
@@ -1105,7 +1105,7 @@ applyChangeAction (ChangeActions action,
    while (fields != NULL)
      {
        const char *fldval = get_field_value (pr, oldPR, fields->ent, NULL, 
NULL);
-      if (fldval == NULL || *fldval == '\0')
+      if (value_is_empty (fldval))
         {
           setError (err, CODE_INVALID_PR_CONTENTS,
                     "Required field %s missing from PR %s.",
Index: file-pr.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/file-pr.c,v
retrieving revision 1.48
diff -u -p -r1.48 file-pr.c
--- file-pr.c   24 Oct 2002 12:45:09 -0000      1.48
+++ file-pr.c   27 Oct 2002 19:29:43 -0000
@@ -446,7 +446,7 @@ missing_required_fields (const DatabaseI
    while (fields != NULL)
      {
        const char *fldval = get_field_value (pr, NULL, fields->ent, NULL, 
NULL);
-      if (fldval == NULL || *fldval == '\0')
+      if (value_is_empty (fldval))
         {
            setError (err, CODE_INVALID_PR_CONTENTS,
                      "Required field %s missing from new PR - cannot submit.",





- Yngve 



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: Required fields on inital PR creation
  2002-10-27 11:37 ` Yngve Svendsen
@ 2002-10-28 11:22   ` Mel Hatzis
  2002-10-28 14:29     ` Yngve Svendsen
  0 siblings, 1 reply; 6+ messages in thread
From: Mel Hatzis @ 2002-10-28 11:22 UTC (permalink / raw)
  To: Yngve Svendsen; +Cc: help-gnats

On 10/27/02 11:36, Yngve Svendsen wrote:
> At 16:42 15.10.2002 -0700, Mel Hatzis wrote:
> 
>> Please review (and hopefully accept) the following patch that fixes a bug
>> in the 'on-change require' functionality and also expands the Gnats 
>> grammar
>> to allow for "required input fields" upon initial PR creation.
>>
>> 1/ The "require { fields }" functionality that's part of the on-change 
>> edit
>>    options for a field is only doing a check for field_value == NULL 
>> right now
>>    (rather than also checking for empty strings). Since field values are
>>    generally initialized to an empty string (upon creation), the 
>> 'require'
>>    clause is basically useless. The patch adds a check for field_value 
>> == "".
>>
>> 2/ It is extremely useful to allow the Gnats administrator to configure
>>    Gnats so that a predefined set of fields must be assigned a value 
>> upon initial
>>    PR creation. Together with the field's own 'on-change require' 
>> clause, this
>>    allows for fields that can never have a null (blank) value.
>>    Allowing the Gnats administrator to enforce non-null fields this 
>> way provides
>>    a powerful mechanism toward improved data integrity.
> 
> 
> This doesn't work quite as it should with multitext fields. If a field 
> is in the initial-entry fields list, both send-pr and Gnatsweb will 
> include it when they submit PRs, even if it is empty. In the submitted 
> PR text, these fields will contain newline character but nothing else. 
> This slips past the require functionality that this patch implements.

Good catch...your patch looks entirely reasonable.

It'd be nice if the Gnats code didn't add newlines for otherwise
blank values - while this may make the display_pr functionality
a little easier, I think it's not very intuitive. Perhaps something
we can improve on for 4.1.

-Mel

> 
> I suggest we also check for space characters, as defined by isspace(), 
> by making the following trivial change:
> 
> Index: edit.c
> ===================================================================
> RCS file: /cvsroot/gnats/gnats/gnats/edit.c,v
> retrieving revision 1.58
> diff -u -p -r1.58 edit.c
> --- edit.c      24 Oct 2002 12:45:09 -0000      1.58
> +++ edit.c      27 Oct 2002 19:29:43 -0000
> @@ -1105,7 +1105,7 @@ applyChangeAction (ChangeActions action,
>    while (fields != NULL)
>      {
>        const char *fldval = get_field_value (pr, oldPR, fields->ent, 
> NULL, NULL);
> -      if (fldval == NULL || *fldval == '\0')
> +      if (value_is_empty (fldval))
>         {
>           setError (err, CODE_INVALID_PR_CONTENTS,
>                     "Required field %s missing from PR %s.",
> Index: file-pr.c
> ===================================================================
> RCS file: /cvsroot/gnats/gnats/gnats/file-pr.c,v
> retrieving revision 1.48
> diff -u -p -r1.48 file-pr.c
> --- file-pr.c   24 Oct 2002 12:45:09 -0000      1.48
> +++ file-pr.c   27 Oct 2002 19:29:43 -0000
> @@ -446,7 +446,7 @@ missing_required_fields (const DatabaseI
>    while (fields != NULL)
>      {
>        const char *fldval = get_field_value (pr, NULL, fields->ent, 
> NULL, NULL);
> -      if (fldval == NULL || *fldval == '\0')
> +      if (value_is_empty (fldval))
>         {
>            setError (err, CODE_INVALID_PR_CONTENTS,
>                      "Required field %s missing from new PR - cannot 
> submit.",
> 
> 
> 
> 
> 
> - Yngve





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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: Required fields on inital PR creation
  2002-10-28 11:22   ` Mel Hatzis
@ 2002-10-28 14:29     ` Yngve Svendsen
  0 siblings, 0 replies; 6+ messages in thread
From: Yngve Svendsen @ 2002-10-28 14:29 UTC (permalink / raw)
  To: hatzis; +Cc: help-gnats

At 11:17 28.10.2002 -0800, Mel Hatzis wrote:
>Good catch...your patch looks entirely reasonable.

Thanks, I'll commit it.

- Yngve 



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-10-28 22:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3DACA802.3060904@juniper.net>
     [not found] ` <200210161242.g9GCgjlU002272@pindari.platypuspartners.com>
2002-10-26 10:42   ` Patch: Required fields on inital PR creation Lars Henriksen
2002-10-26 15:12     ` Yngve Svendsen
     [not found] ` <5.2.0.5.0.20021026235808.00b43f80@ms-etro01-01.norway.sun. com>
2002-10-27  3:16   ` Yngve Svendsen
2002-10-27 11:37 ` Yngve Svendsen
2002-10-28 11:22   ` Mel Hatzis
2002-10-28 14:29     ` Yngve Svendsen

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).