aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm22
-rw-r--r--perllib/FixMyStreet/App/Controller/Council.pm21
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm7
3 files changed, 25 insertions, 25 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 2bfd52633..82d920b3e 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -220,24 +220,14 @@ sub check_location_is_acceptable : Private {
my $lat = $c->stash->{latitude};
my $lon = $c->stash->{longitude};
- # Check this location is okay to be displayed for the cobrand
- my ( $success, $error_msg ) = $c->cobrand->council_check( #
- { lat => $lat, lon => $lon },
- 'submit_problem'
- );
-
# If in UK and we have a lat,lon coocdinate check it is in UK
- if ( !$error_msg && $lat && $c->config->{COUNTRY} eq 'GB' ) {
+ if ( $lat && $c->config->{COUNTRY} eq 'GB' ) {
eval { Utils::convert_latlon_to_en( $lat, $lon ); };
- $error_msg =
- _( "We had a problem with the supplied co-ordinates - outside the UK?"
- ) if $@;
- }
-
- # show error
- if ($error_msg) {
- $c->stash->{location_error} = $error_msg;
- return;
+ if ($@) {
+ $c->stash->{location_error} =
+ _( "We had a problem with the supplied co-ordinates - outside the UK?" );
+ return;
+ }
}
# check that there are councils that can accept this location
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index 53f7e38d8..35e3d0d11 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -48,10 +48,23 @@ sub load_and_check_councils : Private {
@area_types = $c->cobrand->area_types();
}
- # TODO: I think we want in_gb_locale around the next line, needs testing
- my $all_councils =
- mySociety::MaPit::call( 'point', "4326/$longitude,$latitude",
- type => \@area_types );
+ # TODO: I think we want in_gb_locale around the MaPit line, needs testing
+ my $all_councils;
+ if ( $c->stash->{fetch_all_areas} ) {
+ my %area_types = map { $_ => 1 } @area_types;
+ my $all_areas =
+ mySociety::MaPit::call( 'point', "4326/$longitude,$latitude" );
+ $c->stash->{all_areas} = $all_areas;
+ $all_councils = {
+ map { $_ => $all_areas->{$_} }
+ grep { $area_types{ $all_areas->{$_}->{type} } }
+ keys %$all_areas
+ };
+ } else {
+ $all_councils =
+ mySociety::MaPit::call( 'point', "4326/$longitude,$latitude",
+ type => \@area_types );
+ }
# Let cobrand do a check
my ( $success, $error_msg ) =
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 46a90384c..375b36a51 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -341,6 +341,7 @@ could be found.
sub determine_location : Private {
my ( $self, $c ) = @_;
+ $c->stash->{fetch_all_areas} = 1;
return 1
if #
( #
@@ -618,11 +619,7 @@ sub process_report : Private {
$report->name( Utils::trim_text( $params{name} ) );
$report->category( _ $params{category} );
- # FIXME: This is more inefficient than old FixMyStreet code,
- # with 2 MaPit point calls per submission now rather than just one.
- my $mapit_query =
- sprintf( "4326/%s,%s", $report->longitude, $report->latitude );
- my $areas = mySociety::MaPit::call( 'point', $mapit_query );
+ my $areas = $c->stash->{all_areas};
$report->areas( ',' . join( ',', sort keys %$areas ) . ',' );
# From earlier in the process.