help-gnats
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removed lines in responsible


From: Lars Henriksen
Subject: Re: Removed lines in responsible
Date: Thu, 24 Oct 2002 13:25:48 +0200
User-agent: Mutt/1.4i

On Mon, Oct 14, 2002 at 09:06:55PM +0200, Yngve Svendsen wrote:
> This is a known problem in Gnatsweb 3.99.3. We hope to have it fixed in a 
> week or so (I have been promised a patch).

Here is a proposal for a solution to the problems gnatsweb has with entries
that have been removed from the responsible file. See also my previous email
in this thread.

It is a general solution for all unknown enumeration type values, not just
responsible. The solution leaves the gnatsweb query format unchanged, i.e.
enumeration values are still returned as integers. The value "unknown" is
introduced and used whenever an enumeration value cannot be displayed, whether
in a query result or on the Edit page. The solution is selfcontained and
requires no changes to dbconfig or files that define enumeration types.
It does not take multienumeration types into account.

The net effect is that for enumeration type values which are undefined,
"unknown" is displayed in query results and is preselected in drop-down menues
on the Edit page (thus forcing an explicit change).

The responsible field is special in that any value is allowed (see dbconfig,
though I am not sure that allow-any-value really is needed). In submitedit()
I have inserted specific checks for "unknown" similar to those in
validate_new_pr() and have removed a check that I don't understand (for a blank
user or responsible). This allows for an entry in the responsible file like

unknown:The name is not in the responsible file - use "view" to see 
it.:gnats-admin

Finally, "unknown" is preselected as Category on the Create page. This is not
related to the other changes. It forces users to select a category. Experience
shows that users often forget to do so; the new PR is then created in the
default category (pending, the first category in the categories file).

Patch follows.

Regards
Lars Henriksen

Index: gnatsweb.pl
===================================================================
RCS file: /cvsroot/gnatsweb/gnatsweb/gnatsweb.pl,v
retrieving revision 1.110
diff -u -r1.110 gnatsweb.pl
--- gnatsweb.pl 14 Oct 2002 23:02:31 -0000      1.110
+++ gnatsweb.pl 24 Oct 2002 11:16:56 -0000
@@ -1069,6 +1069,11 @@
 
     if (fieldinfo($_, 'fieldtype') eq "enum")
     {
+      # Force choice of category.
+      if ($_ eq $CATEGORY_FIELD) {
+        push(@values, "unknown") if (!grep /^unknown$/, @values);
+        $default = "unknown";
+      }
       print popup_or_scrolling_menu($_, @values, $default),
             "</td>\n</tr>\n";
     }
@@ -1562,7 +1567,13 @@
 
     if (fieldinfo ($_, 'fieldtype') eq 'enum')
     {
-      print popup_or_scrolling_menu($_, @values, $fields{$_}),
+      my $default = $fields{$_};
+      # Check whether field value is a known enumeration value.
+      if (!grep /^$default$/, @values) {
+        push(@values, 'unknown') if (!grep /^unknown$/, @values);
+        $default = 'unknown';
+      }
+      print popup_or_scrolling_menu($_, address@hidden, $default),
             "</td>\n</tr>\n";
     }
     elsif (fieldinfo ($_, 'fieldtype') eq 'multienum')
@@ -1724,11 +1735,20 @@
       last LOCKED;
     }
 
-    if($db_prefs{'user'} eq "" || $fields{$RESPONSIBLE_FIELD} eq "")
-    {
-# dtb this appears to make it impossible to edit a PR with a blank
-# Responsible field.  this might not be the right thing to do...
-      error_page("Responsible party is '$fields{$RESPONSIBLE_FIELD}', user is 
'$db_prefs{'user'}'");
+    my (@errors) = ();
+    if ($fields{$RESPONSIBLE_FIELD} eq "unknown") {
+      push(@errors, "$RESPONSIBLE_FIELD is 'unknown'");
+    }
+    if ($fields{$CATEGORY_FIELD} eq "unknown") {
+      push(@errors, "$CATEGORY_FIELD is 'unknown'.");
+    }
+    if($fields{$SUBMITTER_ID_FIELD} eq "unknown") {
+      push(@errors, "$SUBMITTER_ID_FIELD is 'unknown'.");
+    }
+    if (@errors) {
+      push(@errors,
+           "Go back to the edit form, correct the errors and submit again.");
+      error_page("The PR has not been submitted.", address@hidden);
       last LOCKED;
     }
 
@@ -2432,7 +2452,9 @@
       if ($fieldtypes[$whichfield] eq 'enum')
       {
         my $enumvals = fieldinfo($columns[$whichfield], 'values');
-        $fieldcontents = $$enumvals[$fieldcontents - 1] || 'invalid';
+       # A zero means that the string is absent from the enumeration type.
+        $fieldcontents =
+         $fieldcontents ? $$enumvals[$fieldcontents - 1] : 'unknown';
       }
       $fieldcontents = $q->escapeHTML($fieldcontents);
       $fieldcontents = nonempty($fieldcontents);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]