aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-06-13 18:39:05 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-06-20 15:02:11 +0100
commite57cbf483790bedfef6496be3c7ffa42882c3ffc (patch)
treed01788502457f801a846cdac78213df5ecdf1ea5 /perllib/FixMyStreet/App/Controller
parenta5f311e5147621f285cf31647ce675c502095882 (diff)
[UK] Remove requirement for fixed body IDs.
Historically in UK cobrands, bodies have had IDs the same as the MapIt area ID they cover. This can be confusing (if you are setting up a dev environment, say) and should not be necessary. This commit removes the requirement entirely, by switching any ID checks to either the name of the body, or the actual area it covers. One note: the body name in the test has to match so that we do not get two bodies both covering 2237 created. This will not be necessary when the tests are compartmentalized in the next commit.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/JSON.pm7
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm4
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm3
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm3
5 files changed, 10 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm
index d3cd33546..762e3c115 100644
--- a/perllib/FixMyStreet/App/Controller/JSON.pm
+++ b/perllib/FixMyStreet/App/Controller/JSON.pm
@@ -105,10 +105,9 @@ sub problems : Local {
foreach my $problem (@problems) {
$problem->name( '' ) if $problem->anonymous == 1;
$problem->service( 'Web interface' ) if $problem->service eq '';
- my $bodies = $problem->bodies;
- if (keys %$bodies) {
- my @body_names = map { $_->name } values %$bodies;
- $problem->bodies_str( join(' and ', @body_names) );
+ my $body_names = $problem->body_names;
+ if (@$body_names) {
+ $problem->bodies_str( join(' and ', @$body_names) );
}
}
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index bc08593de..6829e01ae 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -258,8 +258,8 @@ sub output_requests : Private {
}
else {
# FIXME Not according to Open311 v2
- my @body_names = map { $_->name } values %{$problem->bodies};
- $request->{agency_responsible} = {'recipient' => [ @body_names ] };
+ my $body_names = $problem->body_names;
+ $request->{agency_responsible} = {'recipient' => $body_names };
}
if ( !$problem->anonymous ) {
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 368bbcf27..b0a98c9d0 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -203,7 +203,8 @@ sub format_problem_for_display : Private {
$c->stash->{add_alert} = 1;
}
- $c->stash->{extra_name_info} = $problem->bodies_str && $problem->bodies_str eq '2482' ? 1 : 0;
+ my $first_body = (values %{$problem->bodies})[0];
+ $c->stash->{extra_name_info} = $first_body && $first_body->name =~ /Bromley/ ? 1 : 0;
$c->forward('generate_map_tags');
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index bd7c5fa8d..823f4d08f 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -934,7 +934,7 @@ sub set_report_extras : Private {
}
}
- $c->cobrand->process_open311_extras( $c, @$contacts[0]->body_id, \@extra )
+ $c->cobrand->process_open311_extras( $c, @$contacts[0]->body, \@extra )
if ( scalar @$contacts );
if ( @extra ) {
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 261a49ec1..59171f97b 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -307,7 +307,8 @@ sub process_update : Private {
my @extra; # Next function fills this, but we don't need it here.
# This is just so that the error checking for these extra fields runs.
# TODO Use extra here as it is used on reports.
- $c->cobrand->process_open311_extras( $c, $update->problem->bodies_str, \@extra );
+ my $body = (values %{$update->problem->bodies})[0];
+ $c->cobrand->process_open311_extras( $c, $body, \@extra );
if ( $c->get_param('fms_extra_title') ) {
my %extras = ();