diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-13 12:12:50 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-06-14 16:36:44 +0100 |
commit | d50aa7fc015250633ad25f05dab315e422d1161c (patch) | |
tree | 38a98995f059cce313ec7f772ef31800117cc24e | |
parent | 4577fc5dd11e016465aec582927a811bd7c16837 (diff) |
[UK] Improve owns_problem &c for use with TfL body
We need to call owns_problem all the time, not just in two-tier areas, for pin
colour and base URL, and ignore TfL in owns_problem and body lookup function.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 753aa2404..25f809d8c 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -38,10 +38,11 @@ sub restriction { return { cobrand => shift->moniker }; } -# UK cobrands assume that each MapIt area ID maps both ways with one body +# UK cobrands assume that each MapIt area ID maps both ways with one +# body. Except TfL. sub body { my $self = shift; - my $body = FixMyStreet::DB->resultset('Body')->for_areas($self->council_area_id)->first; + my $body = FixMyStreet::DB->resultset('Body')->for_areas($self->council_area_id)->search({ name => { '!=', 'TfL' } })->first; return $body; } @@ -175,28 +176,27 @@ sub owns_problem { } else { # Object @bodies = values %{$report->bodies}; } - my %areas = map { %{$_->areas} } @bodies; + # Want to ignore the TfL body that covers London councils + my %areas = map { %{$_->areas} } grep { $_->name ne 'TfL' } @bodies; return $areas{$self->council_area_id} ? 1 : undef; } -# If the council is two-tier then show pins for the other council as grey +# If the council is two-tier, or e.g. TfL reports, +# 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 'grey' if !$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 +# If we ever link to a county problem report, or a TfL report, +# needs to be to main FixMyStreet sub base_url_for_report { my ( $self, $report ) = @_; - if ( $self->is_two_tier ) { - if ( $self->owns_problem( $report ) ) { - return $self->base_url; - } else { - return FixMyStreet->config('BASE_URL'); - } - } else { + if ( $self->owns_problem( $report ) ) { return $self->base_url; + } else { + return FixMyStreet->config('BASE_URL'); } } |