diff options
author | Matthew Somerville <matthew@mysociety.org> | 2015-12-02 17:33:48 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2015-12-15 17:02:11 +0000 |
commit | 92dfeac83378cd49fbb59591685e5bf849d317e6 (patch) | |
tree | f87175f6539728e319dc5bd027b1b94fd7eaa26b /perllib/FixMyStreet/Cobrand | |
parent | 64d24b8627879fc68f9f883d6e24a9c7cb72449f (diff) |
Fix cobrand restriction of My/Nearby.
5c79337 simplified a bit too far, as after then a particular cobrand
could in Nearby and My only filter reports to a particular body, not
any other criteria. To fix this, introduce more generic functions in
the default cobrand to allow more flexibility.
Make sure a few tests delete their bodies fully so that new tests
pass when run as part of the suite.
Fixes #1289.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 35 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/SeeSomething.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 16 |
3 files changed, 36 insertions, 20 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 48c997047..e7a4dad72 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -47,24 +47,45 @@ sub country { =head1 problems -Returns a ResultSet of Problems, restricted to a subset if we're on a cobrand -that only wants some of the data. +Returns a ResultSet of Problems, potentially restricted to a subset if we're on +a cobrand that only wants some of the data. =cut sub problems { my $self = shift; - return $self->{c}->model('DB::Problem'); + return $self->problems_restriction($self->{c}->model('DB::Problem')); } -=head1 body_restriction +=head1 updates -Return an extra query parameter to restrict reports to those sent to a -particular body. +Returns a ResultSet of Comments, potentially restricted to a subset if we're on +a cobrand that only wants some of the data. =cut -sub body_restriction {} +sub updates { + my $self = shift; + return $self->updates_restriction($self->{c}->model('DB::Comment')); +} + +=head1 problems_restriction/updates_restriction + +Used to restricts reports and updates in a cobrand in a particular way. Do +nothing by default. + +=cut + +sub problems_restriction { + my ($self, $rs) = @_; + return $rs; +} + +sub updates_restriction { + my ($self, $rs) = @_; + return $rs; +} + sub site_key { return 0; } diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm index 9ae15fd8d..22750aafa 100644 --- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm +++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm @@ -10,11 +10,6 @@ sub council_name { return 'See Something Say Something'; } sub council_url { return 'seesomething'; } sub area_types { [ 'MTD' ] } -sub body_restriction { - my $self = shift; - return $self->council_id; -} - sub area_check { my ( $self, $params, $context ) = @_; diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 0fb8c23d0..b4b91b7dd 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -22,11 +22,6 @@ sub path_to_web_templates { ]; } -sub body_restriction { - my $self = shift; - return $self->council_id; -} - sub site_key { my $self = shift; return $self->council_url; @@ -36,9 +31,14 @@ sub restriction { return { cobrand => shift->moniker }; } -sub problems { - my $self = shift; - return $self->{c}->model('DB::Problem')->to_body($self->council_id); +sub problems_restriction { + my ($self, $rs) = @_; + return $rs->to_body($self->council_id); +} + +sub updates_restriction { + my ($self, $rs) = @_; + return $rs->to_body($self->council_id); } sub base_url { |