aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-04-15 17:49:13 +0100
committerDave Arter <davea@mysociety.org>2016-07-08 15:30:41 +0100
commit8a8b34b66dbdb9d2ce9c5b2d00318d75ef93d267 (patch)
tree94158b497072156c273f442ce19888665a205a2c
parent18b68734f0d425875a4e3abbd4416a7952d1089f (diff)
[UK Councils] Show all reports on cobrand /around map
There is a concern that excluding district council reports from a two-tier council's cobrand's /around page might lead to duplicate reports or reports never being seen. This commit adds them to the map and the sidebar and displays the destination council in the report list item. Clicking the pin or the report link leads to the report on FMS.com. Reports sent to the a council other than the the active cobrand are shown as grey pins on the map, and the receiving council's name is shown in the sidebar list.
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm25
-rw-r--r--perllib/FixMyStreet/Cobrand/EastSussex.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm7
-rw-r--r--perllib/FixMyStreet/Map.pm4
-rw-r--r--templates/web/base/maps/noscript_map.html2
-rw-r--r--templates/web/base/report/_item.html23
-rw-r--r--templates/web/oxfordshire/reports/_list-entry.html1
9 files changed, 53 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index b8f038ce3..f8ea84d08 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -195,6 +195,7 @@ sub display_location : Private {
colour => $colour,
id => $p->id,
title => $p->title_safe,
+ problem => $p,
}
} @$on_map_all, @$around_map;
}
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 65c97f38b..36313cf63 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -74,6 +74,18 @@ sub problems {
return $self->problems_restriction($self->{c}->model('DB::Problem'));
}
+=head1 problems_on_map
+
+Returns a ResultSet of Problems to be shown on the /around map, potentially
+restricted to a subset if we're on a cobrand that only wants some of the data.
+
+=cut
+
+sub problems_on_map {
+ my $self = shift;
+ return $self->problems_on_map_restriction($self->{c}->model('DB::Problem'));
+}
+
=head1 updates
Returns a ResultSet of Comments, potentially restricted to a subset if we're on
@@ -115,6 +127,19 @@ sub categories_restriction {
return $rs;
}
+
+=head1 problems_on_map_restriction
+
+Used to restricts reports shown on the /around map in a cobrand in a particular way. Do
+nothing by default.
+
+=cut
+
+sub problems_on_map_restriction {
+ my ($self, $rs) = @_;
+ return $rs;
+}
+
sub site_key { return 0; }
=head2 restriction
diff --git a/perllib/FixMyStreet/Cobrand/EastSussex.pm b/perllib/FixMyStreet/Cobrand/EastSussex.pm
index 2ba3a4f70..80a86706a 100644
--- a/perllib/FixMyStreet/Cobrand/EastSussex.pm
+++ b/perllib/FixMyStreet/Cobrand/EastSussex.pm
@@ -113,6 +113,8 @@ sub reports_per_page { return 20; }
sub pin_colour {
my ( $self, $p, $context ) = @_;
+ return 'grey' unless $self->owns_problem( $p );
+
# TODO refactor to a Moo(se)? lazy attribute
my $open_states = $self->{open_states} ||= $p->open_states;
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index 3b044369e..d127f5e13 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -98,6 +98,7 @@ sub reports_ordering {
sub pin_colour {
my ( $self, $p, $context ) = @_;
+ return 'grey' unless $self->owns_problem( $p );
return 'grey' if $p->state eq 'not responsible';
return 'green' if $p->is_fixed || $p->is_closed;
return 'red' if $p->state eq 'confirmed';
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 6bf70e091..6e98f4ae0 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -129,6 +129,13 @@ sub owns_problem {
return $areas{$self->council_id} ? 1 : undef;
}
+# If the council is two-tier then show pins for the other council as grey
+sub pin_colour {
+ my ( $self, $p, $context ) = @_;
+ return 'grey' if $self->is_two_tier && !$self->owns_problem( $p );
+ return $self->next::method($p, $context);
+}
+
# If we ever link to a county problem report, needs to be to main FixMyStreet
sub base_url_for_report {
my ( $self, $report ) = @_;
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 6d641331f..b8b128611 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -100,9 +100,9 @@ sub _map_features {
my $around_limit = $c->cobrand->on_map_list_limit || undef;
my @around_args = ( $min_lat, $max_lat, $min_lon, $max_lon, $interval );
- my $around_map = $c->cobrand->problems->around_map( @around_args, undef, $category, $states );
+ my $around_map = $c->cobrand->problems_on_map->around_map( @around_args, undef, $category, $states );
my $around_map_list = $around_limit
- ? $c->cobrand->problems->around_map( @around_args, $around_limit, $category, $states )
+ ? $c->cobrand->problems_on_map->around_map( @around_args, $around_limit, $category, $states )
: $around_map;
my $dist = FixMyStreet::Gaze::get_radius_containing_population( $lat, $lon );
diff --git a/templates/web/base/maps/noscript_map.html b/templates/web/base/maps/noscript_map.html
index bce562a59..f35f152e8 100644
--- a/templates/web/base/maps/noscript_map.html
+++ b/templates/web/base/maps/noscript_map.html
@@ -54,7 +54,7 @@
[% BLOCK pin %]
[% IF pin.id %]
-<a title="[% pin.title | html %]" href="[% c.uri_for('/report/' _ pin.id) %]">
+<a title="[% pin.title | html %]" href="[% c.cobrand.base_url_for_report( pin.problem ) %][% pin.problem.url %]">
[%- END -%]
<img border="0" class="pin" src="[% start %][% c.cobrand.path_to_pin_icons _ 'pin-' _ pin.colour _ '.png' %]"
alt="[% loc('Problem') %]" style="top:[% pin.py - 64 %]px; left:[% pin.px - 24 %]px; position: absolute;">
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index 704dfd29c..5894c5d81 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -1,5 +1,5 @@
<li class="item-list__item item-list--reports__item [% item_extra_class %]">
-<a href="[% c.uri_for('/report', problem.id ) %]">
+<a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %]">
[% IF problem.photo %]
<img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt="">
[% END %]
@@ -14,15 +14,18 @@
[%- IF problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %],
[% tprintf(loc('last updated %s'), prettify_dt( problem.lastupdate, 1 ) ) %]
[%- END %]
- [% IF include_sentinfo %]
- [% IF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %]
- [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %]
+ [% IF include_sentinfo %]
+ [% IF c.cobrand.is_council && !c.cobrand.owns_problem( problem ) %]
+ (sent to [% problem.body %])
+ [% ELSIF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %]
+ [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %]
+ [% END %]
[% END %]
- [% END %]
- [% IF NOT no_fixed AND problem.is_fixed %]
- [% loc('(fixed)') %]
- [% ELSIF NOT no_fixed AND problem.is_closed %]
- [% loc('(closed)') %]
- [% END %]</small>
+ [% IF NOT no_fixed AND problem.is_fixed %]
+ [% loc('(fixed)') %]
+ [% ELSIF NOT no_fixed AND problem.is_closed %]
+ [% loc('(closed)') %]
+ [% END %]
+ </small>
</a>
</li>
diff --git a/templates/web/oxfordshire/reports/_list-entry.html b/templates/web/oxfordshire/reports/_list-entry.html
index 43d3d6265..76b135665 100644
--- a/templates/web/oxfordshire/reports/_list-entry.html
+++ b/templates/web/oxfordshire/reports/_list-entry.html
@@ -1,4 +1,5 @@
[% INCLUDE 'report/_item.html'
no_fixed = 1
+ include_sentinfo = 1
item_extra_class = 'item-list__item--with-pin ' _ c.cobrand.pin_colour(problem)
%]