diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/IsleOfWight.pm | 9 |
3 files changed, 21 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index cebc4ed85..ebb3d4839 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -234,11 +234,12 @@ sub check_and_stash_category : Private { my @list_of_names = map { $_->name } values %bodies; my $csv = Text::CSV->new(); $csv->combine(@list_of_names); + $c->stash->{bodies} = \@bodies; $c->{stash}->{list_of_names_as_string} = $csv->string; my $where = { body_id => [ keys %bodies ], }; - my $cobrand_where = $c->cobrand->call_hook('munge_category_where', $where ); + my $cobrand_where = $c->cobrand->call_hook('munge_around_category_where', $where ); if ( $cobrand_where ) { $where = $cobrand_where; } @@ -257,7 +258,7 @@ sub check_and_stash_category : Private { my $categories = [ $c->get_param_list('filter_category', 1) ]; my %valid_categories = map { $_ => 1 } grep { $_ && $categories_mapped{$_} } @$categories; $c->stash->{filter_category} = \%valid_categories; - $c->cobrand->call_hook('munge_filter_category'); + $c->cobrand->call_hook('munge_around_filter_category_list'); } sub map_features : Private { @@ -318,7 +319,7 @@ sub ajax : Path('/ajax') { my %valid_categories = map { $_ => 1 } $c->get_param_list('filter_category', 1); $c->stash->{filter_category} = \%valid_categories; - $c->cobrand->call_hook('munge_filter_category'); + $c->cobrand->call_hook('munge_around_filter_category_list'); $c->forward('map_features', [ { bbox => $c->stash->{bbox} } ]); $c->forward('/reports/ajax', [ 'around/on_map_list_items.html' ]); diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index bfa991b09..705b623d4 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -38,6 +38,20 @@ sub restriction { return {}; } +sub munge_around_category_where { + my ($self, $where) = @_; + + my $user = $self->{c}->user; + my @iow = grep { $_->name eq 'Isle of Wight Council' } @{ $self->{c}->stash->{bodies} }; + return unless @iow; + + # display all the categories on Isle of Wight at the moment as there's no way to + # do the expand bit later as we fetch it using ajax which uses a bounding box so + # can't determine the body + $where->{send_method} = [ { '!=' => 'Triage' }, undef ]; + return $where; +} + sub munge_reports_categories_list { my ($self, $categories) = @_; diff --git a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm index dd4b936d7..b43802d92 100644 --- a/perllib/FixMyStreet/Cobrand/IsleOfWight.pm +++ b/perllib/FixMyStreet/Cobrand/IsleOfWight.pm @@ -123,16 +123,13 @@ sub munge_category_list { @$options = grep { my $c = ($_->{category} || $_->category); $c =~ 'Pick a category' || $seen->{ $c } } @$options; } -sub munge_category_where { +sub munge_around_category_where { my ($self, $where) = @_; my $user = $self->{c}->user; my $b = $self->{c}->model('DB::Body')->for_areas( $self->council_area_id )->first; if ( $user && ( $user->is_superuser || $user->belongs_to_body( $b->id ) ) ) { - $where = { - body_id => $where->{body_id}, - send_method => [ { '!=' => 'Triage' }, undef ], - }; + $where->{send_method} = [ { '!=' => 'Triage' }, undef ]; return $where; } @@ -152,7 +149,7 @@ sub munge_load_and_group_problems { return $problems; } -sub munge_filter_category { +sub munge_around_filter_category_list { my $self = shift; my $c = $self->{c}; |