diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 20 |
5 files changed, 26 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index d90a46b32..0c26220e0 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -222,7 +222,7 @@ sub check_location_is_acceptable : Private { my $lon = $c->stash->{longitude}; # If in UK and we have a lat,lon coocdinate check it is in UK - if ( $lat && $c->config->{COUNTRY} eq 'GB' ) { + if ( $lat && $c->cobrand->country eq 'GB' ) { eval { Utils::convert_latlon_to_en( $lat, $lon ); }; if ($@) { $c->stash->{location_error} = diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 643e4bd8f..dfa45df55 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -156,7 +156,7 @@ sub report_import : Path('/import') { push @errors, 'Please enter a valid email'; } - if ( $latitude && $c->config->{COUNTRY} eq 'GB' ) { + if ( $latitude && $c->cobrand->country eq 'GB' ) { eval { Utils::convert_latlon_to_en( $latitude, $longitude ); }; push @errors, "We had a problem with the supplied co-ordinates - outside the UK?" diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index e81a28bd2..47bee1e0a 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -71,6 +71,16 @@ sub path_to_web_templates { return FixMyStreet->path_to( 'templates/web', $self->moniker ); } +=head1 country + +Returns the country that this cobrand operates in, as an ISO3166-alpha2 code. + +=cut + +sub country { + return 'GB'; +} + =head1 problems_clause Returns a hash for a query to be used by problems (and elsewhere in joined diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index eb7ea89a5..694e952f2 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -7,6 +7,10 @@ use warnings; use Carp; use mySociety::MaPit; +sub country { + return 'NO'; +} + sub set_lang_and_domain { my ( $self, $lang, $unicode, $dir ) = @_; mySociety::Locale::negotiate_language( diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index a520a2daa..423cec9b6 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -38,20 +38,20 @@ BEGIN { sub lookup { my ($s, $c) = @_; my ($latitude, $longitude, $error); - if (mySociety::Config::get('COUNTRY') eq 'GB') { + if ( $c->cobrand->country eq 'GB') { if ($s =~ /^\d+$/) { $error = 'FixMyStreet is a UK-based website that currently works in England, Scotland, and Wales. Please enter either a postcode, or a Great British street name and area.'; } elsif (mySociety::PostcodeUtil::is_valid_postcode($s)) { my $location = mySociety::MaPit::call('postcode', $s); - unless ($error = mapit_check_error($location)) { + unless ( $error = mapit_check_error( $c, $location ) ) { $latitude = $location->{wgs84_lat}; $longitude = $location->{wgs84_lon}; } } - } elsif (mySociety::Config::get('COUNTRY') eq 'NO') { + } elsif ( $c->cobrand->country eq 'NO') { if ($s =~ /^\d{4}$/) { my $location = mySociety::MaPit::call('postcode', $s); - unless ($error = mapit_check_error($location)) { + unless ( $error = mapit_check_error( $c, $location ) ) { $latitude = $location->{wgs84_lat}; $longitude = $location->{wgs84_lon}; } @@ -64,7 +64,7 @@ sub lookup { } sub geocoded_string_coordinates { - my ( $js ) = @_; + my ( $c, $js ) = @_; my ($latitude, $longitude, $error); my ($accuracy) = $js =~ /"Accuracy" *: *(\d)/; if ($accuracy < 4) { @@ -72,7 +72,7 @@ sub geocoded_string_coordinates { } elsif ( $js =~ /"coordinates" *: *\[ *(.*?), *(.*?),/ ) { $longitude = $1; $latitude = $2; - if (mySociety::Config::get('COUNTRY') eq 'GB') { + if ( $c->cobrand->country eq 'GB') { try { my ($easting, $northing) = Utils::convert_latlon_to_en( $latitude, $longitude ); } catch Error::Simple with { @@ -98,7 +98,7 @@ sub results_check { push (@valid_locations, $_); } if (scalar @valid_locations == 1) { - return geocoded_string_coordinates( $valid_locations[0] ); + return geocoded_string_coordinates( $c, $valid_locations[0] ); } $error = _('Sorry, we could not find that location.') unless $error; return (undef, undef, $error); @@ -128,7 +128,7 @@ sub string { # think we are in the UK for some locations so we explictly add UK to # the address. We do it here so as not to invalidate existing cache # entries - if ( mySociety::Config::get('COUNTRY') eq 'GB' + if ( $c->cobrand->country eq 'GB' && $url !~ /,\+UK/ && $url !~ /united\++kingdom$/ ) { @@ -160,12 +160,12 @@ sub string { } sub mapit_check_error { - my $location = shift; + my ( $c, $location ) = @_; if ($location->{error}) { return _('That postcode was not recognised, sorry.') if $location->{code} =~ /^4/; return $location->{error}; } - if (mySociety::Config::get('COUNTRY') eq 'GB') { + if ( $c->cobrand->country eq 'GB') { my $island = $location->{coordsyst}; if (!$island) { return _("Sorry, that appears to be a Crown dependency postcode, which we don't cover."); |