Skip to content

Commit

Permalink
[Zurich] Fix call to admin_fetch_all_bodies.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Oct 22, 2018
1 parent b57df33 commit e6b5590
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions perllib/FixMyStreet/App/Controller/Admin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2211,13 +2211,14 @@ sub check_page_allowed : Private {
sub fetch_all_bodies : Private {
my ($self, $c ) = @_;

my @bodies = $c->cobrand->call_hook('admin_fetch_all_bodies') || do {
my @bodies = $c->cobrand->call_hook('admin_fetch_all_bodies');
if (!@bodies) {
my $bodies = $c->model('DB::Body')->search(undef, {
columns => [ "id", "name", "deleted", "parent" ],
})->with_parent_name;
$bodies = $bodies->with_defect_type_count if $c->stash->{with_defect_type_count};
$bodies->translated->all_sorted;
};
@bodies = $bodies->translated->all_sorted;
}

$c->stash->{bodies} = \@bodies;

Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Zurich.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ sub admin_fetch_all_bodies {

my %sorted;
foreach (@bodies) {
my $p = $_->{parent} || 0;
my $p = $_->{parent}{id} || 0;
push @{$sorted{$p}}, $_;
}

Expand Down
1 change: 1 addition & 0 deletions t/cobrand/zurich.t
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ subtest "only superuser can see 'Add body' form" => sub {
}, sub {
$mech->get_ok( '/admin/bodies' );
};
$mech->content_contains('External Body');
$mech->content_lacks( '<form method="post" action="bodies"' );
$mech->log_out_ok;
};
Expand Down

0 comments on commit e6b5590

Please sign in to comment.