aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-09-01 10:07:30 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-09-03 16:14:18 +0100
commit8544bafc365406ac9a403e80fe07cc361a7d1d5b (patch)
treeda90a4a20c9f3d653335b3c8369b900211b47dd0 /perllib/FixMyStreet/Cobrand
parent8ef9368785c1950ae0aea8c13584288d395662d6 (diff)
Use base URL in cobrand alert for no-body report.
If a cobrand has a body restriction, then a report without any body won't be shown on it, so we need to make sure links to the report (in email alerts and RSS) are to the base URL, not the cobrand.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm3
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm11
2 files changed, 11 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 8cd392073..c347d5750 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -108,7 +108,8 @@ sub base_url { FixMyStreet->config('BASE_URL') }
=head2 base_url_for_report
Return the base url for a report (might be different in a two-tier county, but
-most of the time will be same as base_url).
+most of the time will be same as base_url). Report may be an object, or a
+hashref.
=cut
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 2c231bc39..074da0915 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -109,8 +109,15 @@ sub recent_photos {
# Returns true if the cobrand owns the problem.
sub owns_problem {
my ($self, $report) = @_;
- my $bodies = $report->bodies;
- my %areas = map { %{$_->areas} } values %$bodies;
+ my @bodies;
+ if (ref $report eq 'HASH') {
+ return unless $report->{bodies_str};
+ @bodies = split /,/, $report->{bodies_str};
+ @bodies = FixMyStreet::App->model('DB::Body')->search({ id => \@bodies })->all;
+ } else { # Object
+ @bodies = values %{$report->bodies};
+ }
+ my %areas = map { %{$_->areas} } @bodies;
return $areas{$self->council_id} ? 1 : undef;
}