aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm16
2 files changed, 18 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index d40a4c61d..e9b4bb9a2 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -587,10 +587,6 @@ sub reports : Path('reports') {
sub report_edit : Path('report_edit') : Args(1) {
my ( $self, $c, $id ) = @_;
- if ( $c->cobrand->moniker eq 'zurich' ) {
- $c->cobrand->admin_bodies();
- }
-
my $site_restriction = $c->cobrand->site_restriction;
my $problem = $c->cobrand->problems->search(
@@ -604,6 +600,10 @@ sub report_edit : Path('report_edit') : Args(1) {
$c->stash->{problem} = $problem;
+ if ( $c->cobrand->moniker eq 'zurich' ) {
+ $c->cobrand->admin_report_edit();
+ }
+
$c->forward('get_token');
$c->forward('check_email_for_abuse', [ $problem->user->email ] );
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 0c362f612..15397e0a2 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -110,17 +110,29 @@ sub admin {
}
}
-sub admin_bodies {
+sub admin_report_edit {
my $self = shift;
my $c = $self->{c};
my $type = $self->admin_type();
+ my $problem = $c->stash->{problem};
+ my $body = $c->stash->{body};
+
+ my %allowed_bodies = map { $_->id => 1 } ( $body->bodies->all, $body );
+ $c->detach( '/page_error_404_not_found' )
+ unless $allowed_bodies{$problem->bodies_str};
+
if ($type eq 'dm') {
- my $body = $c->stash->{body};
my @bodies = $c->model('DB::Body')->search( [ { parent => $body->parent->id }, { parent => $body->id } ] );
@bodies = sort { strcoll($a->name, $b->name) } @bodies;
$c->stash->{bodies} = \@bodies;
+ } elsif ($type eq 'sdm') {
+ $c->stash->{template} = 'admin/report_edit-sdm.html';
+ my @bodies = $c->model('DB::Body')->search( [ { id => $body->parent->id }, { id => $body->id } ] );
+ @bodies = sort { strcoll($a->name, $b->name) } @bodies;
+ $c->stash->{bodies} = \@bodies;
}
+
}
1;