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/App/Controller/Admin.pm | |
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/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 9a6c7bded..0fc87c2f6 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -84,7 +84,7 @@ sub index : Path : Args(0) { for ( FixMyStreet::DB::Result::Problem->visible_states() ); $c->stash->{total_problems_users} = $c->cobrand->problems->unique_users; - my $comments = $c->model('DB::Comment')->summary_count( $c->cobrand->body_restriction ); + my $comments = $c->cobrand->updates->summary_count; my %comment_counts = map { $_->state => $_->get_column('state_count') } $comments->all; @@ -171,7 +171,7 @@ sub timeline : Path( 'timeline' ) : Args(0) { push @{$time{$_->whenanswered->epoch}}, { type => 'quesAnswered', date => $_->whenanswered, obj => $_ } if $_->whenanswered; } - my $updates = $c->model('DB::Comment')->timeline( $c->cobrand->body_restriction ); + my $updates = $c->cobrand->updates->timeline; foreach ($updates->all) { push @{$time{$_->created->epoch}}, { type => 'update', date => $_->created, obj => $_} ; @@ -622,9 +622,7 @@ sub reports : Path('reports') { } if (@$query) { - my $updates = $c->model('DB::Comment') - ->to_body($c->cobrand->body_restriction) - ->search( + my $updates = $c->cobrand->updates->search( { -or => $query, }, @@ -967,9 +965,7 @@ sub users: Path('users') : Args(0) { sub update_edit : Path('update_edit') : Args(1) { my ( $self, $c, $id ) = @_; - my $update = $c->model('DB::Comment') - ->to_body($c->cobrand->body_restriction) - ->search({ id => $id })->first; + my $update = $c->cobrand->updates->search({ id => $id })->first; $c->detach( '/page_error_404_not_found' ) unless $update; |