Skip to content

Commit

Permalink
Show all reports in report admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
abeverley committed Sep 22, 2024
1 parent 80b3bc4 commit f4f87ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/GADS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
{
Expand Down
18 changes: 7 additions & 11 deletions lib/GADS/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ has _user_permissions_columns => (
clearer => 1,
);

has reports=> (
is => 'lazy',
isa => ArrayRef,
);

has security_marking => (
is => 'lazy',
);
Expand All @@ -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];
}
Expand Down

0 comments on commit f4f87ef

Please sign in to comment.