Module: tools
Branch: master
Commit: b1a19b109f4faa7e33aaea5bea2f656c1a367ff0
URL: https://source.winehq.org/git/tools.git/?a=commit;h=b1a19b109f4faa7e33aaea5…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Jun 8 16:41:23 2022 +0200
testbot/orm: Turn Itemrefs into virtual properties.
Itemref properties are used to map foreign key columns to the object
corresponding to the target table row. However so far adding an
Itemref property meant hiding the underlying table column(s) with
annoying side-effects:
* The type of the underlying property is unknown which is not an issue
for strings and integers but rules out using booleans and timestamps
in foreign keys since they need conversion from / to the database
format.
* Filtering on an Itemref property is possible by passing the target
object, but not by using the underlying property(s). This makes
inequality filters (e.g. >= JobId) awkward or impossible.
* This also makes it impossible to filter on a partial foreign key.
For instance if one had a TaskFailures table matching known failures
to the tasks (JobId, TaskNo) they appear in, one would be unable to
get a collection with all the entries for a given job since it's
impossible to filter on just the JobId column.
So this modifies Itemref properties to come in addition to the
underlying column instead of replacing them.
This means declaring all the underlying columns, with their proper
property descriptors, which makes it possible to access them the
normal way and to use them in filters, while still being able to
access the corresponding object using the extra Itemref 'virtual'
property.
It also means filtering out the new properties if they should not be
shown in the GUI.
Another consequence is that Itemref properties cannot be keys: only
the underlying columns can.
Finally the underlying columns should not be modified directly as
that would cause them to be inconsistent with the corresponding Itemref
property but this is not enforced.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/DBIBackEnd.pm | 26 ++++++++++++++--------
testbot/lib/ObjectModel/Item.pm | 25 ++++++---------------
.../lib/ObjectModel/ItemrefPropertyDescriptor.pm | 17 +++++++++-----
testbot/lib/WineTestBot/CGI/Sessions.pm | 1 +
testbot/lib/WineTestBot/Jobs.pm | 3 +++
testbot/lib/WineTestBot/PendingPatches.pm | 1 +
testbot/lib/WineTestBot/StepsTasks.pm | 1 +
testbot/lib/WineTestBot/Tasks.pm | 1 +
testbot/lib/WineTestBot/UserRoles.pm | 3 ++-
testbot/web/JobDetails.pl | 6 ++---
testbot/web/index.pl | 11 +++------
11 files changed, 50 insertions(+), 45 deletions(-)
Diff: https://source.winehq.org/git/tools.git/?a=commitdiff;h=b1a19b109f4faa7e33a…
Module: tools
Branch: master
Commit: 0c435f5126a9165ca7513a57ef5e6444451c1693
URL: https://source.winehq.org/git/tools.git/?a=commit;h=0c435f5126a9165ca7513a5…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Jun 8 16:41:06 2022 +0200
testbot/cgi: Rename ItemPage::RedirectToList() to RedirectToParent().
The parent of a Details page may not be a *List.pl page.
For instance a naive web interface for a Job -> Step hierarchy would
result in a JobsList -> JobDetails -> StepsList -> StepDetails page
tree. But such a page hierarchy would be very cumbersome to use so one
would instead have JobsList -> JobDetails (with embedded StepsBlock) ->
StepDetails. So the StepDetails page would link back to the JobDetails
page and not to a *List page.
So a better name for the redirect method is the more generic
RedirectToParent().
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/ObjectModel/CGI/ItemPage.pm | 6 +++---
testbot/web/admin/UserDetails.pl | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/ItemPage.pm b/testbot/lib/ObjectModel/CGI/ItemPage.pm
index 690458e..cd40ba2 100644
--- a/testbot/lib/ObjectModel/CGI/ItemPage.pm
+++ b/testbot/lib/ObjectModel/CGI/ItemPage.pm
@@ -125,7 +125,7 @@ sub GetActions($)
return $self->{HasRW} ? ["Save", "Cancel"] : [];
}
-sub RedirectToList($)
+sub RedirectToParent($)
{
my ($self) = @_;
@@ -139,11 +139,11 @@ sub OnAction($$)
if ($Action eq "Save")
{
return !1 if (!$self->Save());
- exit($self->RedirectToList());
+ exit($self->RedirectToParent());
}
if ($Action eq "Cancel")
{
- exit($self->RedirectToList());
+ exit($self->RedirectToParent());
}
return $self->SUPER::OnAction($Action);
diff --git a/testbot/web/admin/UserDetails.pl b/testbot/web/admin/UserDetails.pl
index 798063d..833a36d 100644
--- a/testbot/web/admin/UserDetails.pl
+++ b/testbot/web/admin/UserDetails.pl
@@ -196,7 +196,7 @@ sub OnApprove($)
return !1 if (!$self->Save());
$self->{ErrMessage} = $self->{Item}->Approve();
return !1 if (defined $self->{ErrMessage});
- exit($self->RedirectToList());
+ exit($self->RedirectToParent());
}
sub OnReject($)
@@ -208,7 +208,7 @@ sub OnReject($)
return !1 if (defined $self->{ErrMessage});
# Forcefully log out that user by deleting his web sessions
DeleteSessions($self->{Item});
- exit($self->RedirectToList());
+ exit($self->RedirectToParent());
}
sub OnSave($)
@@ -221,7 +221,7 @@ sub OnSave($)
# Forcefully log out that user by deleting his web sessions
DeleteSessions($self->{Item});
}
- exit($self->RedirectToList());
+ exit($self->RedirectToParent());
}
sub OnAction($$)