Call Validate() to make sure the Hours parameter is usable. Note that due to an implementation detail marking the Hours property as required is not strictly necessary. But it does reflect that we need a value for the Download action. Use SetParam() to provide a default value which removes the need for redefining GetPropertyValue(). Treat "00" the same as "0".
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/web/admin/Log.pl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/testbot/web/admin/Log.pl b/testbot/web/admin/Log.pl index 456e73f55d..f8e4943b3d 100644 --- a/testbot/web/admin/Log.pl +++ b/testbot/web/admin/Log.pl @@ -34,9 +34,16 @@ sub _initialize($$$) my ($self, $Request, $RequiredRole) = @_;
my @PropertyDescriptors = ( - CreateBasicPropertyDescriptor("Hours", "Hours", !1, !1, "N", 2), + CreateBasicPropertyDescriptor("Hours", "Hours", !1, 1, "N", 2), ); $self->SUPER::_initialize($Request, $RequiredRole, @PropertyDescriptors); + + if (!$self->GetParam("Hours") or !$self->Validate() or + !int($self->GetParam("Hours"))) # 00 case! + { + $self->SetParam("Hours", 1) if (!defined $self->{ErrMessage}); + $self->SetParam("Action", undef); + } }
sub GetPageTitle($$) @@ -46,16 +53,6 @@ sub GetPageTitle($$) return "Engine Log - ${ProjectName} Test Bot"; }
-sub GetPropertyValue($$) -{ - my ($self, $PropertyDescriptor) = @_; - - my $PropertyName = $PropertyDescriptor->GetName(); - return 1 if ($PropertyName eq "Hours"); # Provides a default value - - return $self->SUPER::GetPropertyValue($PropertyDescriptor); -} - sub GetHeaderText($) { #my ($self) = @_;
The action is pretty simple so there is no need for a separate function.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/web/admin/Log.pl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/testbot/web/admin/Log.pl b/testbot/web/admin/Log.pl index f8e4943b3d..ddc655f6d6 100644 --- a/testbot/web/admin/Log.pl +++ b/testbot/web/admin/Log.pl @@ -65,18 +65,14 @@ sub GetActions($) return ["Download"]; }
-sub OnDownload($) -{ - my ($self) = @_; - - exit($self->Redirect("/admin/SendLog.pl?Hours=". $self->GetParam("Hours"))); -} - sub OnAction($$) { my ($self, $Action) = @_;
- return $self->OnDownload() if ($Action eq "Download"); + if ($Action eq "Download") + { + exit($self->Redirect("/admin/SendLog.pl?Hours=". $self->GetParam("Hours"))); + } return $self->SUPER::OnAction($Action); }