aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm3
-rw-r--r--perllib/FixMyStreet/App/Controller/Council.pm4
-rwxr-xr-xperllib/FixMyStreet/App/Controller/FakeMapit.pm53
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm24
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyBarangay.pm44
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm8
7 files changed, 134 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 3047b195c..f2bb23350 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -45,7 +45,7 @@ sub around_index : Path : Args(0) {
|| $c->forward('/location/determine_location_from_pc');
# Check to see if the spot is covered by a council - if not show an error.
- return unless $c->forward('check_location_is_acceptable');
+ return unless $c->cobrand->moniker eq 'fixmybarangay' || $c->forward('check_location_is_acceptable');
# If we have a partial - redirect to /report/new so that it can be
# completed.
@@ -204,6 +204,7 @@ sub display_location : Private {
longitude => $short_longitude,
clickable => 1,
pins => \@pins,
+ area => $c->cobrand->areas_on_around,
);
return 1;
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index 48248e4fe..7a0f9b73f 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -37,6 +37,7 @@ there are no councils then return false.
sub load_and_check_councils : Private {
my ( $self, $c ) = @_;
+
my $latitude = $c->stash->{latitude};
my $longitude = $c->stash->{longitude};
@@ -82,8 +83,9 @@ sub load_and_check_councils : Private {
$c->cobrand->remove_redundant_councils($all_councils) if $c->stash->{remove_redundant_councils};
# If we don't have any councils we can't accept the report
- if ( !scalar keys %$all_councils ) {
+ if ( !scalar keys %$all_councils || $all_councils->{error}) {
$c->stash->{location_offshore} = 1;
+ $c->stash->{location_error} = 'That point is outside the boundaries.';
return;
}
diff --git a/perllib/FixMyStreet/App/Controller/FakeMapit.pm b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
new file mode 100755
index 000000000..bc46df712
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
@@ -0,0 +1,53 @@
+package FixMyStreet::App::Controller::FakeMapit;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+FixMyStreet::App::Controller::FakeMapit - Catalyst Controller
+
+=head1 DESCRIPTION
+
+A controller to fake mapit when we don't have it. If you set MAPIT_URL to
+.../fakemapit/ it should all just work, with a mapit that assumes the whole
+world is one area, with ID 161 and name "Default Area".
+
+=head1 METHODS
+
+=cut
+
+my $area = { "name" => "Default Area", "type" => "ZZZ", "id" => 161 };
+
+sub output : Private {
+ my ( $self, $c, $data ) = @_;
+ my $body = JSON->new->utf8(1)->encode( $data );
+ $c->res->content_type('application/json; charset=utf-8');
+ $c->res->body( $body );
+}
+
+sub point : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ { 161 => $area } ] );
+}
+
+sub area : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ $area ] );
+}
+
+sub areas : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ { 161 => $area } ] );
+}
+
+sub children : Path('area/161/children') : Args(0) {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ {} ] );
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 9fb72121e..c5f709054 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -43,6 +43,7 @@ sub index : Path : Args(0) {
$c->stash->{message} = _("Unable to look up areas in MaPit. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
+ return;
}
# For each area, add its link and perhaps alter its name if we need to for
@@ -70,6 +71,7 @@ sub index : Path : Args(0) {
$c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
+ return;
}
# Down here so that error pages aren't cached.
@@ -126,7 +128,7 @@ sub ward : Path : Args(2) {
# List of wards
unless ($c->stash->{ward}) {
- my $children = mySociety::MaPit::call('area/children', $c->stash->{council}->{id},
+ my $children = mySociety::MaPit::call('area/children', [ $c->stash->{council}->{id} ],
type => $mySociety::VotingArea::council_child_types,
);
foreach (values %$children) {
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index b06c534ac..87bd2d316 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -134,7 +134,7 @@ Parameter is QUERY
=cut
-sub enter_postcode_text { '' }
+sub enter_postcode_text { _('Enter a nearby street name and area') }
=head2 all_reports_style
@@ -636,8 +636,8 @@ The MaPit types this site handles
=cut
-sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
-sub area_min_generation { 10 }
+sub area_types { qw(ZZZ) }
+sub area_min_generation { '' }
=head2 contact_name, contact_email
@@ -963,6 +963,24 @@ sub example_places {
return [ 'B2 4QA', 'Tib St, Manchester' ];
}
+=head2 only_authed_can_create
+
+If true, only users with the from_council flag set are able to create reports.
+
+=cut
+
+sub only_authed_can_create {
+ return 0;
+}
+
+=head2 areas_on_around
+
+If set to an arrayref, will plot those area ID(s) from mapit on all the /around pages.
+
+=cut
+
+sub areas_on_around {}
+
sub process_extras {}
=head 2 pin_colour
diff --git a/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm b/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm
new file mode 100644
index 000000000..51d49242d
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/FixMyBarangay.pm
@@ -0,0 +1,44 @@
+package FixMyStreet::Cobrand::FixMyBarangay;
+use base 'FixMyStreet::Cobrand::Default';
+
+use strict;
+use warnings;
+
+sub path_to_web_templates {
+ my $self = shift;
+ return [
+ FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
+ FixMyStreet->path_to( 'templates/web/fixmystreet' )->stringify
+ ];
+}
+
+sub country {
+ return 'PH';
+}
+
+sub area_types {
+ return ( 'BGY' );
+}
+
+sub disambiguate_location {
+ return {
+ country => 'ph',
+ bing_country => 'Philippines',
+ };
+}
+
+sub site_title {
+ my ($self) = @_;
+ return 'FixMyBarangay';
+}
+
+sub only_authed_can_create {
+ return 1;
+}
+
+sub areas_on_around {
+ return [ 1, 2 ];
+}
+
+1;
+
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index d32e876bb..fbc48449c 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -1,11 +1,19 @@
package FixMyStreet::Cobrand::FixMyStreet;
use base 'FixMyStreet::Cobrand::Default';
+sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
+sub area_min_generation { 10 }
+
# FixMyStreet should return all cobrands
sub restriction {
return {};
}
+sub enter_postcode_text {
+ my ( $self ) = @_;
+ return _("Enter a nearby GB postcode, or street name and area");
+}
+
sub admin_base_url {
return 'https://secure.mysociety.org/admin/bci/';
}