From f4f87eff22b58e3844c1c9ee79294ac0488ba545 Mon Sep 17 00:00:00 2001 From: Andy Beverley Date: Sun, 22 Sep 2024 11:19:42 +0100 Subject: [PATCH] Show all reports in report admin page --- lib/GADS.pm | 2 +- lib/GADS/Layout.pm | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/GADS.pm b/lib/GADS.pm index 217a6208a..bacdf3c84 100644 --- a/lib/GADS.pm +++ b/lib/GADS.pm @@ -2810,7 +2810,7 @@ prefix '/:layout_name' => sub { my $base_url = request->base; - my $reports = $layout->reports; + my $reports = $layout->reports(all => 1); if (my $report_id = body_parameters->get('delete')) { diff --git a/lib/GADS/Layout.pm b/lib/GADS/Layout.pm index e20e78b53..e99a83296 100644 --- a/lib/GADS/Layout.pm +++ b/lib/GADS/Layout.pm @@ -295,11 +295,6 @@ has _user_permissions_columns => ( clearer => 1, ); -has reports=> ( - is => 'lazy', - isa => ArrayRef, -); - has security_marking => ( is => 'lazy', ); @@ -309,16 +304,17 @@ sub _build_security_marking { $self->_rset->read_security_marking; } -sub _build_reports -{ my $self = shift; +sub reports +{ my ($self, %options) = @_; my $user = $self->user; - # Even if a user is a super-admin or layout admin, only show them relevant - # reports - my $reports_rs = $self->schema->resultset('Report')->by_user($user)->search({ + # By default only show a user their own reports, unless this is an admin + # request to manage all reports + my $reports_rs = $self->schema->resultset('Report'); + $reports_rs = $reports_rs->by_user($user)->search({ instance_id => $self->instance_id, - }); + }) unless $options{all} && $self->user_can("layout"); [$reports_rs->all]; }