aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Hounslow.pm149
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm2
-rw-r--r--perllib/FixMyStreet/Map/Hounslow.pm68
5 files changed, 225 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index a09161494..203296c4d 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -416,7 +416,7 @@ sub lookup_by_ref : Private {
external_id => $ref
];
- my $problems = $c->cobrand->problems->search( $criteria );
+ my $problems = $c->cobrand->problems->search({ non_public => 0, -or => $criteria });
my $count = try {
$problems->count;
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 10c869aee..1c5aae647 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -201,6 +201,10 @@ sub report_form_ajax : Path('ajax') : Args(0) {
my $extra_titles_list = $c->cobrand->title_list($c->stash->{all_areas});
my @list_of_names = map { $_->name } values %{$c->stash->{bodies}};
+ my %display_names = map {
+ my $name = $_->get_cobrand_handler ? $_->get_cobrand_handler->council_name : $_->name;
+ ( $_->name ne $name ) ? ( $_->name => $name ) : ();
+ } values %{$c->stash->{bodies}};
my $contribute_as = {};
if ($c->user_exists) {
my @bodies = keys %{$c->stash->{bodies}};
@@ -227,6 +231,7 @@ sub report_form_ajax : Path('ajax') : Args(0) {
category => $category,
extra_name_info => $extra_name_info,
titles_list => $extra_titles_list,
+ %display_names ? (display_names => \%display_names) : (),
%$contribute_as ? (contribute_as => $contribute_as) : (),
$top_message ? (top_message => $top_message) : (),
unresponsive => $c->stash->{unresponsive}->{ALL} || '',
diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm
new file mode 100644
index 000000000..7ebd62a18
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm
@@ -0,0 +1,149 @@
+package FixMyStreet::Cobrand::Hounslow;
+use parent 'FixMyStreet::Cobrand::Whitelabel';
+
+use strict;
+use warnings;
+
+sub council_area_id { 2483 }
+sub council_area { 'Hounslow' }
+sub council_name { 'Hounslow Highways' }
+sub council_url { 'hounslow' }
+sub example_places { ( 'TW3 1SN', "Depot Road" ) }
+
+sub map_type { 'Hounslow' }
+
+sub base_url {
+ my $self = shift;
+ return $self->next::method() if FixMyStreet->config('STAGING_SITE');
+ return 'https://fms.hounslowhighways.org';
+}
+
+sub enter_postcode_text {
+ my ($self) = @_;
+ return "Enter a Hounslow street name and area, or postcode";
+}
+
+sub admin_user_domain { 'hounslowhighways.org' }
+
+sub disambiguate_location {
+ my $self = shift;
+ my $string = shift;
+
+ my $town = "Hounslow";
+
+ # Some specific Hounslow roads produce lots of geocoder results
+ # for the same road; this picks just one.
+ ( $string, $town ) = ( "TW3 4HR", "" ) if $string =~ /lampton\s+road/i;
+ ( $string, $town ) = ( "TW3 4AJ", "" ) if $string =~ /kingsley\s+road/i;
+ ( $string, $town ) = ( "TW3 1YQ", "" ) if $string =~ /stanborough\s+road/i;
+
+ return {
+ %{ $self->SUPER::disambiguate_location() },
+ string => $string,
+ centre => '51.468495,-0.366134',
+ town => $town,
+ bounds => [ 51.420739, -0.461502, 51.502850, -0.243443 ],
+ };
+}
+
+sub get_geocoder {
+ return 'OSM'; # default of Bing gives poor results, let's try overriding.
+}
+
+sub on_map_default_status { 'open' }
+
+sub contact_email {
+ my $self = shift;
+ return join( '@', 'enquiries', $self->council_url . 'highways.org' );
+}
+
+sub send_questionnaires { 0 }
+
+sub enable_category_groups { 1 }
+
+sub categories_restriction {
+ my ($self, $rs) = @_;
+ # Categories covering the Hounslow area have a mixture of Open311 and Email
+ # send methods. Hounslow only want Open311 categories to be visible on their
+ # cobrand, not the email categories from FMS.com. We've set up the
+ # Email categories with a devolved send_method, so can identify Open311
+ # categories as those which have a blank send_method.
+ return $rs->search( { 'me.send_method' => undef, 'body.name' => 'Hounslow Borough Council' } );
+}
+
+sub report_sent_confirmation_email { 'external_id' }
+
+# Used to change the "Sent to" line on report pages
+sub link_to_council_cobrand { "Hounslow Highways" }
+
+# The "all reports" link will default to using council_name, which
+# in our case doesn't correspond to a body and so causes an infinite redirect.
+# Instead, force the borough council name to be used.
+sub all_reports_single_body { { name => "Hounslow Borough Council" } }
+
+sub open311_post_send {
+ my ($self, $row, $h) = @_;
+
+ # Check Open311 was successful
+ return unless $row->external_id;
+
+ my $e = join( '@', 'enquiries', $self->council_url . 'highways.org' );
+ my $sender = FixMyStreet::SendReport::Email->new( to => [ [ $e, 'Hounslow Highways' ] ] );
+ $sender->send($row, $h);
+}
+
+sub open311_config {
+ my ($self, $row, $h, $params) = @_;
+
+ my $extra = $row->get_extra_fields;
+ push @$extra,
+ { name => 'report_url',
+ value => $h->{url} },
+ { name => 'title',
+ value => $row->title },
+ { name => 'description',
+ value => $row->detail };
+
+ # Reports made via FMS.com or the app probably won't have a site code
+ # value because we don't display the adopted highways layer on those
+ # frontends. Instead we'll look up the closest asset from the WFS
+ # service at the point we're sending the report over Open311.
+ if (!$row->get_extra_field_value('site_code')) {
+ if (my $site_code = $self->lookup_site_code($row)) {
+ push @$extra,
+ { name => 'site_code',
+ value => $site_code };
+ }
+ }
+
+ $row->set_extra_fields(@$extra);
+
+ $params->{multi_photos} = 1;
+}
+
+sub open311_munge_update_params {
+ my ($self, $params, $comment, $body) = @_;
+
+ # Hounslow want to make it clear in Confirm when an update is left by
+ # someone who's not the original reporter.
+ unless ($comment->user eq $comment->problem->user) {
+ $params->{description} = "[This comment was not left by the original problem reporter] " . $params->{description};
+ }
+}
+
+sub open311_skip_report_fetch {
+ my ($self, $problem) = @_;
+
+ return 1 if $problem->non_public;
+}
+
+sub lookup_site_code_config { {
+ buffer => 50, # metres
+ url => "https://tilma.mysociety.org/mapserver/hounslow",
+ srsname => "urn:ogc:def:crs:EPSG::27700",
+ typename => "streets",
+ property => "SITE_CODE",
+ accept_feature => sub { 1 }
+} }
+
+1;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 09ca6c535..c21ed6401 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -282,6 +282,8 @@ sub lookup_site_code {
my $response = get($uri);
+ return '' unless $response;
+
my $j = JSON->new->utf8->allow_nonref;
try {
$j = $j->decode($response);
diff --git a/perllib/FixMyStreet/Map/Hounslow.pm b/perllib/FixMyStreet/Map/Hounslow.pm
new file mode 100644
index 000000000..ce0831196
--- /dev/null
+++ b/perllib/FixMyStreet/Map/Hounslow.pm
@@ -0,0 +1,68 @@
+# FixMyStreet:Map::Hounslow
+# Hounslow use their own tiles on their cobrand
+
+package FixMyStreet::Map::Hounslow;
+use base 'FixMyStreet::Map::UKCouncilWMTS';
+
+use strict;
+
+sub default_zoom { 5; }
+
+sub urls { [ 'https://gis.ringway.co.uk/server/rest/services/Hosted/HounslowOSBasemap/MapServer/WMTS/tile' ] }
+
+sub layer_names { [ 'Hosted_HounslowOSBasemap' ] }
+
+sub scales {
+ my $self = shift;
+ my @scales = (
+ # The first 5 levels don't load and are really zoomed-out, so
+ # they're not included here.
+ # '600000',
+ # '500000',
+ # '400000',
+ # '300000',
+ # '200000',
+ '100000',
+ '75000',
+ '50000',
+ '25000',
+ '10000',
+ '8000',
+ '6000',
+ '4000',
+ '2000',
+ '1000',
+ '400',
+ );
+ return @scales;
+}
+
+sub zoom_parameters {
+ my $self = shift;
+ my $params = {
+ zoom_levels => scalar $self->scales,
+ default_zoom => $self->default_zoom,
+ min_zoom_level => 0,
+ id_offset => 5, # see note above about zoom layers we've skipped
+ };
+ return $params;
+}
+
+sub copyright {
+ return 'Contains Ordnance Survey data &copy; Crown copyright and database rights 2019 OS. Use of this data is subject to <a href="/about/mapterms">terms and conditions</a>.';
+}
+
+
+sub map_javascript { [
+ '/vendor/OpenLayers/OpenLayers.wmts.js',
+ '/vendor/OpenLayers.Projection.OrdnanceSurvey.js',
+ '/js/map-OpenLayers.js',
+ '/js/map-wmts-base.js',
+ '/js/map-wmts-hounslow.js',
+ '/cobrands/fixmystreet-uk-councils/roadworks.js',
+ '/cobrands/fixmystreet/assets.js',
+ '/cobrands/hounslow/js.js',
+ '/cobrands/hounslow/assets.js',
+] }
+
+1;