aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm14
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm35
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm3
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm6
-rw-r--r--perllib/FixMyStreet/Geocode.pm12
7 files changed, 35 insertions, 48 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index b380eedfc..ec1fde4e4 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -217,20 +217,6 @@ and that they are in UK (if we are in UK).
sub check_location_is_acceptable : Private {
my ( $self, $c ) = @_;
- # These should be set now
- my $lat = $c->stash->{latitude};
- my $lon = $c->stash->{longitude};
-
- # If in UK and we have a lat,lon coocdinate check it is in UK
- if ( $lat && $c->cobrand->country eq 'GB' ) {
- eval { Utils::convert_latlon_to_en( $lat, $lon ); };
- 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
$c->stash->{council_check_action} = 'submit_problem';
$c->stash->{remove_redundant_councils} = 1;
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index c1b119074..9f8260768 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -39,7 +39,7 @@ sub determine_location_from_coords : Private {
$c->stash->{pc} = $pc;
}
- return 1;
+ return $c->forward( 'check_location' );
}
return;
@@ -65,19 +65,13 @@ sub determine_location_from_pc : Private {
$c->stash->{pc} = $pc; # for template
my ( $latitude, $longitude, $error ) =
- eval { FixMyStreet::Geocode::lookup( $pc, $c ) };
-
- # Check that nothing blew up
- if ($@) {
- warn "Error: $@";
- return;
- }
+ FixMyStreet::Geocode::lookup( $pc, $c );
# If we got a lat/lng set to stash and return true
if ( defined $latitude && defined $longitude ) {
$c->stash->{latitude} = $latitude;
$c->stash->{longitude} = $longitude;
- return 1;
+ return $c->forward( 'check_location' );
}
# $error doubles up to return multiple choices by being an array
@@ -97,6 +91,29 @@ sub determine_location_from_pc : Private {
return;
}
+=head2 check_location
+
+Just make sure that for UK installs, our co-ordinates are indeed in the UK.
+
+=cut
+
+sub check_location : Private {
+ my ( $self, $c ) = @_;
+
+ if ( $c->stash->{latitude} && $c->cobrand->country eq 'GB' ) {
+ eval { Utils::convert_latlon_to_en( $c->stash->{latitude}, $c->stash->{longitude} ); };
+ if (my $error = $@) {
+ mySociety::Locale::pop(); # We threw exception, so it won't have happened.
+ $error = _('That location does not appear to be in Britain; please try again.')
+ if $error =~ /of the area covered/;
+ $c->stash->{location_error} = $error;
+ return;
+ }
+ }
+
+ return 1;
+}
+
=head1 AUTHOR
Struan Donald
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 5506e2dbd..19d057958 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -79,7 +79,7 @@ sub submit : Path('submit') {
} elsif ( $c->req->params->{problem} ) {
$c->forward('submit_creator_fixed');
} else {
- return;
+ $c->detach( '/page_error_404_not_found' );
}
return 1;
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 3f7bd268f..58b689bf9 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -168,6 +168,7 @@ sub council_check : Private {
my ( $self, $c, $q_council ) = @_;
$q_council =~ s/\+/ /g;
+ $q_council =~ s/\.html//;
# Manual misspelling redirect
if ($q_council =~ /^rhondda cynon taff$/i) {
@@ -224,6 +225,8 @@ sub ward_check : Private {
my ( $self, $c, $ward ) = @_;
$ward =~ s/\+/ /g;
+ $ward =~ s/\.html//;
+
my $council = $c->stash->{council};
my $qw = mySociety::MaPit::call('areas', $ward,
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index c23d5d1fc..9019568f8 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -615,16 +615,7 @@ Return if we are the virtual host that sends email for this cobrand
=cut
sub email_host {
- my $self = shift;
- my $cobrand_moniker_uc = uc( $self->moniker );
-
- my $email_vhost =
- mySociety::Config::get("EMAIL_VHOST_$cobrand_moniker_uc", '')
- || mySociety::Config::get("EMAIL_VHOST")
- || '';
-
- return $email_vhost
- && "http://$email_vhost" eq mySociety::Config::get("BASE_URL");
+ return 1;
}
=item remove_redundant_councils
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index 7fe27fd2e..29d2ec867 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -13,10 +13,12 @@ sub country {
sub set_lang_and_domain {
my ( $self, $lang, $unicode, $dir ) = @_;
- mySociety::Locale::negotiate_language(
- 'en-gb,English,en_GB|nb,Norwegian,nb_NO', 'nb' );
+ my $set_lang = mySociety::Locale::negotiate_language(
+ 'en-gb,English,en_GB|nb,Norwegian,nb_NO', 'nb'
+ );
mySociety::Locale::gettext_domain( 'FixMyStreet', $unicode, $dir );
mySociety::Locale::change();
+ return $set_lang;
}
sub enter_postcode_text {
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index 423cec9b6..d5cc7f1d3 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -10,14 +10,12 @@ package FixMyStreet::Geocode;
use strict;
use Encode;
-use Error qw(:try);
use File::Slurp;
use File::Path ();
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
use URI::Escape;
-use Utils;
use mySociety::Config;
use mySociety::Locale;
use mySociety::MaPit;
@@ -72,16 +70,6 @@ sub geocoded_string_coordinates {
} elsif ( $js =~ /"coordinates" *: *\[ *(.*?), *(.*?),/ ) {
$longitude = $1;
$latitude = $2;
- if ( $c->cobrand->country eq 'GB') {
- try {
- my ($easting, $northing) = Utils::convert_latlon_to_en( $latitude, $longitude );
- } catch Error::Simple with {
- mySociety::Locale::pop(); # We threw exception, so it won't have happened.
- $error = shift;
- $error = _('That location does not appear to be in Britain; please try again.')
- if $error =~ /out of the area covered/;
- }
- }
}
return ($latitude, $longitude, $error);
}