diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-10-22 12:42:03 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-10-22 14:58:35 +0100 |
commit | b5f57d1649b7dee104e29e8c5055a09e1de06b70 (patch) | |
tree | 3479010f71b39f749b11d53dd39a9c7aabde40c1 | |
parent | b57df33a0714d6ee6fb897887eb20b0387321afc (diff) |
[Zurich] Fix call to admin_fetch_all_bodies.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 2 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 1 |
3 files changed, 6 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index d757cec9a..75684c773 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -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; diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 7740474ab..4098c6708 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -1096,7 +1096,7 @@ sub admin_fetch_all_bodies { my %sorted; foreach (@bodies) { - my $p = $_->{parent} || 0; + my $p = $_->{parent} ? $_->{parent}{id} : 0; push @{$sorted{$p}}, $_; } diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index 2f60231ab..45888771d 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -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; }; |