diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 11 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index a0bcdb4d0..806fc8391 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -221,16 +221,13 @@ sub admin_type { my $body = $c->user->from_body; $c->stash->{body} = $body; - my $parent = $body->parent; - my $children = $body->bodies->count; - my $type; + my $parent = $body->parent; if (!$parent) { $type = 'super'; - } elsif ($parent && $children) { - $type = 'dm'; - } elsif ($parent) { - $type = 'sdm'; + } else { + my $grandparent = $parent->parent; + $type = $grandparent ? 'sdm' : 'dm'; } $c->stash->{admin_type} = $type; diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index c750b6070..ac0cc52b3 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -19,6 +19,8 @@ $mech->content_like( qr/zurich/i ); # Set up bodies my $zurich = $mech->create_body_ok( 1, 'Zurich' ); +$zurich->parent( undef ); +$zurich->update; my $division = $mech->create_body_ok( 2, 'Division 1' ); $division->parent( $zurich->id ); $division->send_method( 'Zurich' ); |