Set the FormPage property descriptors list. This allows
FormPage::Validate() to do most of the validation work.
Treat "00" the same as "0".
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/web/Activity.pl | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/testbot/web/Activity.pl b/testbot/web/Activity.pl
index 9444779433..272215f958 100644
--- a/testbot/web/Activity.pl
+++ b/testbot/web/Activity.pl
@@ -27,28 +27,35 @@ …
[View More]our @ISA = qw(ObjectModel::CGI::FreeFormPage);
use POSIX qw(strftime);
use URI::Escape;
+use ObjectModel::BasicPropertyDescriptor;
use WineTestBot::Config;
use WineTestBot::Activity;
use WineTestBot::Log; # For Elapsed()
use WineTestBot::Utils;
use WineTestBot::VMs;
-
my $HOURS_DEFAULT = 12;
+
sub _initialize($$$)
{
my ($self, $Request, $RequiredRole) = @_;
$self->{start} = Time();
- $self->{hours} = $self->GetParam("Hours");
- if (!defined $self->{hours} or $self->{hours} !~ /^\d{1,3}$/)
- {
- $self->{hours} = $HOURS_DEFAULT;
- }
-
+ my @PropertyDescriptors = (
+ CreateBasicPropertyDescriptor("Hours", "Hours", !1, 1, "N", 3),
+ );
$self->SUPER::_initialize($Request, $RequiredRole);
$self->{Method} = "get";
+
+ if (!$self->GetParam("Hours") or !$self->Validate() or
+ !int($self->GetParam("Hours"))) # 00 case!
+ {
+ # This page always needs a valid value to calculate the cutoff. So just
+ # replace invalid values with the default (no error message is shown
+ # either).
+ $self->SetParam("Hours", $HOURS_DEFAULT);
+ }
}
sub GetPageTitle($$)
@@ -61,7 +68,8 @@ sub GetPageTitle($$)
sub GeneratePage($)
{
my ($self) = @_;
- if ($self->{hours} and $self->{hours} <= $HOURS_DEFAULT)
+
+ if ($self->GetParam("Hours") <= $HOURS_DEFAULT)
{
$self->{Request}->headers_out->add("Refresh", "60");
}
@@ -101,7 +109,7 @@ sub GenerateBody($)
# Generate a custom form to let the user specify the Hours field.
$self->GenerateFormStart();
- print "<div class='ItemProperty'><label>Analyze the activity of the past <div class='ItemValue'><input type='text' name='Hours' maxlength='3' size='3' value='$self->{hours}'/></div> hours.</label></div>\n";
+ print "<div class='ItemProperty'><label>Analyze the activity of the past <div class='ItemValue'><input type='text' name='Hours' maxlength='3' size='3' value='", $self->GetParam("Hours"), "'/></div> hours.</label></div>\n";
$self->GenerateFormEnd();
print "<h1>${ProjectName} Test Bot activity</h1>\n";
@@ -148,7 +156,7 @@ EOF
### Generate the HTML table with the newest record first
print "<tbody>\n";
- my ($Activity, $_Counters) = GetActivity($VMs, $self->{hours} * 3600);
+ my ($Activity, $_Counters) = GetActivity($VMs, $self->GetParam("Hours") * 3600);
for (my $Index = @$Activity; $Index--; )
{
my $Group = $Activity->[$Index];
--
2.30.2
[View Less]
Store it in a variable at the start of the file so it's easy to spot.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/web/admin/Log.pl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/testbot/web/admin/Log.pl b/testbot/web/admin/Log.pl
index ddc655f6d6..8d3a8ce8b7 100644
--- a/testbot/web/admin/Log.pl
+++ b/testbot/web/admin/Log.pl
@@ -28,6 +28,8 @@ use ObjectModel::BasicPropertyDescriptor;
use WineTestBot::Config;
use WineTestBot::Log;
+…
[View More]my $HOURS_DEFAULT = 1;
+
sub _initialize($$$)
{
@@ -41,7 +43,7 @@ sub _initialize($$$)
if (!$self->GetParam("Hours") or !$self->Validate() or
!int($self->GetParam("Hours"))) # 00 case!
{
- $self->SetParam("Hours", 1) if (!defined $self->{ErrMessage});
+ $self->SetParam("Hours", $HOURS_DEFAULT) if (!defined $self->{ErrMessage});
$self->SetParam("Action", undef);
}
}
--
2.30.2
[View Less]
Also better document why each type of field can or cannot be edited /
shown.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/lib/ObjectModel/CGI/FormPage.pm | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/FormPage.pm b/testbot/lib/ObjectModel/CGI/FormPage.pm
index 3ac62239d5..e432fcbbd2 100644
--- a/testbot/lib/ObjectModel/CGI/FormPage.pm
+++ b/testbot/lib/ObjectModel/CGI/FormPage.pm
@@ -208,6 …
[View More]+208,8 @@ sub GetInputType($$)
{
my ($self, $PropertyDescriptor) = @_;
+ # Note: Editing Detailrefs and Itemrefs is not supported which leaves only
+ # Basic and Enum property descriptors here.
return $PropertyDescriptor->GetClass() eq "Enum" ? "select" :
$PropertyDescriptor->GetType() eq "B" ? "checkbox" :
$PropertyDescriptor->GetType() eq "textarea" ? "textarea" :
@@ -331,12 +333,20 @@ sub DisplayProperty($$)
{
my ($self, $PropertyDescriptor) = @_;
- if ($PropertyDescriptor->GetClass() eq "Detailref")
- {
- return "";
- }
-
- return "rw";
+ return # Detailref fields point to a Collection of objects matching the
+ # primary key of this form data. As such they can neither be shown
+ # nor edited.
+ $PropertyDescriptor->GetClass() eq "Detailref" ? "" :
+ # Itemref fields are keys identifying other objects and thus would
+ # require careful validation if edited. Requiring users to manually
+ # type the appropriate key value would also be cumbersome so this is
+ # currently not supported. But they can be displayed.
+ $PropertyDescriptor->GetClass() eq "Itemref" ? "ro" :
+ # All other properties can be edited...
+ $PropertyDescriptor->GetClass() ne "Basic" ? "rw" :
+ $PropertyDescriptor->GetType() ne "S" ? "rw" :
+ # ...except autoincrement ones (shown as <unset> if undefined)
+ "ro";
}
sub GetActions($)
--
2.30.2
[View Less]
They don't have a value yet and cannot be edited.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/lib/ObjectModel/CGI/ItemPage.pm | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/ItemPage.pm b/testbot/lib/ObjectModel/CGI/ItemPage.pm
index 940115475f..a178aa6e09 100644
--- a/testbot/lib/ObjectModel/CGI/ItemPage.pm
+++ b/testbot/lib/ObjectModel/CGI/ItemPage.pm
@@ -99,13 +99,16 @@ sub DisplayProperty($$…
[View More])
my ($self, $PropertyDescriptor) = @_;
my $Display = $self->SUPER::DisplayProperty($PropertyDescriptor);
- if ($Display eq "rw" && ! $self->{Item}->GetIsNew() &&
- $PropertyDescriptor->GetIsKey())
- {
- $Display = "";
- }
-
- return $Display;
+ return # Don't show autoincrement fields of new items: they don't have a
+ # value yet and cannot be edited anyway so there is no point.
+ ($PropertyDescriptor->GetClass() eq "Basic" and
+ $PropertyDescriptor->GetType() eq "S" and
+ $self->{Item}->GetIsNew()) ? "" :
+ # Don't allow editing key attributes of existing items. Furthermore
+ # the item is identified in the page title so hide them altogether.
+ ($PropertyDescriptor->GetIsKey() and !$self->{Item}->GetIsNew() and
+ $Display eq "rw") ? "" :
+ $Display;
}
sub GetActions($)
--
2.30.2
[View Less]
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
winetest/patterns.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/winetest/patterns.js b/winetest/patterns.js
index be583a5f0c..042620b8f4 100644
--- a/winetest/patterns.js
+++ b/winetest/patterns.js
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- *Foundation, Inc., 59 Temple Place, Suite …
[View More]330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
"use strict";
--
2.30.2
[View Less]