diff options
author | Dave Arter <davea@mysociety.org> | 2016-07-08 10:27:14 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-07-08 14:29:28 +0100 |
commit | 49207ca458921d79527b832efce32f7ab0dfe6c0 (patch) | |
tree | c0fe2fa2494fec0b75ab7e1dd6188fe6010da041 | |
parent | 5cc37b53df6eef31e94dfe5e434ae149068bc892 (diff) |
[Bristol] Only show Open311 categories on Bristol cobrand
This adds a new Cobrand::Default::categories_restriction method that can be used
to limit what categories are available when making a new report on a per-cobrand
basis.
This is used by Cobrand::Bristol to only show Open311 categories when making a
new report on fixmystreet.bristol.gov.uk but allowing all categories on FMS.com.
Also removes the Hart::hidden_categories and uses the new categories_restriction
method to achieve the same thing.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 15 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bristol.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Hart.pm | 7 |
4 files changed, 27 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 9779a5e2a..c4a2162a8 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -602,12 +602,12 @@ sub setup_categories_and_bodies : Private { my %bodies = map { $_->id => $_ } @bodies; my $first_body = ( values %bodies )[0]; - my @contacts # + my $contacts # = $c # ->model('DB::Contact') # ->not_deleted # - ->search( { body_id => [ keys %bodies ] } ) - ->all; + ->search( { body_id => [ keys %bodies ] } ); + my @contacts = $c->cobrand->categories_restriction($contacts)->all; # variables to populate my %bodies_to_list = (); # Bodies with categories assigned @@ -670,15 +670,6 @@ sub setup_categories_and_bodies : Private { $c->cobrand->munge_category_list(\@category_options, \@contacts, \%category_extras) if $c->cobrand->can('munge_category_list'); - if ($c->cobrand->can('hidden_categories')) { - my %hidden_categories = map { $_ => 1 } - $c->cobrand->hidden_categories; - - @category_options = grep { - !$hidden_categories{$_} - } @category_options; - } - # put results onto stash for display $c->stash->{bodies} = \%bodies; $c->stash->{all_body_names} = [ map { $_->name } values %bodies ]; diff --git a/perllib/FixMyStreet/Cobrand/Bristol.pm b/perllib/FixMyStreet/Cobrand/Bristol.pm index a6bab287a..faf2b5f0a 100644 --- a/perllib/FixMyStreet/Cobrand/Bristol.pm +++ b/perllib/FixMyStreet/Cobrand/Bristol.pm @@ -55,4 +55,14 @@ sub send_questionnaires { return 0; } +sub categories_restriction { + my ($self, $rs) = @_; + # Categories covering the Bristol area have a mixture of Open311 and Email + # send methods. Bristol 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( { send_method => undef } ); +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 5c7ce10c4..65c97f38b 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -103,6 +103,17 @@ sub updates_restriction { return $rs; } +=head1 categories_restriction + +Used to restrict categories available when making new report in a cobrand in a +particular way. Do nothing by default. + +=cut + +sub categories_restriction { + my ($self, $rs) = @_; + return $rs; +} sub site_key { return 0; } diff --git a/perllib/FixMyStreet/Cobrand/Hart.pm b/perllib/FixMyStreet/Cobrand/Hart.pm index 185539cb6..42c4a636e 100644 --- a/perllib/FixMyStreet/Cobrand/Hart.pm +++ b/perllib/FixMyStreet/Cobrand/Hart.pm @@ -30,10 +30,9 @@ sub example_places { return ( 'GU51 4JX', 'Primrose Drive' ); } -sub hidden_categories { - return ( - 'Graffiti on bridges/subways', - ); +sub categories_restriction { + my ($self, $rs) = @_; + return $rs->search( { category => { '!=' => 'Graffiti on bridges/subways' } } ); } sub send_questionnaires { |