aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/SeeSomething.pm
diff options
context:
space:
mode:
authorSteven Day <steve@mysociety.org>2014-07-29 16:46:04 +0100
committerHakim Cassimally <hakim@mysociety.org>2014-07-31 11:17:07 +0000
commit0c254d386b2580bdcd2ffea43391acc1e682a6d4 (patch)
treeb72206ec087a1db50bc2cd7102b446882b486a4c /perllib/FixMyStreet/Cobrand/SeeSomething.pm
parent9a8fa132b6718b7f994476b4175f81fceebe337e (diff)
Replace from_council with from_body in SeeSomething cobrand
'from_council' was renamed to 'from_body' and turned into a relationship in b2aa34b Feb 2013, and the seesomething code was missed. Though the FMS::DB::Result::User object would (correctly) throw an error if an invalid method is called, *Catalyst* idea of a user object wraps this in a Catalyst::Authentication::Store::DBIx::Class which uses AUTOLOAD to delegate methods and swallows the error. e.g. this code always returns false, hence the code path is never run. (I think this is a bug and have opened: https://rt.cpan.org/Ticket/Display.html?id=97640 ) Added test case and (hopefully) corrected template, will need a check against site running copy with recent data to check that nothing looks squiffy. We also had to change the %council_details stash, which was based on the old code, not sure if suggested fix matches original intent, but looks plausible. (As discussed with @dracos @stevenday this is slightly repeated, and should arguably use ->{bodies} but that's a possible future FIXME)
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/SeeSomething.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/SeeSomething.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
index e5e937267..af386429c 100644
--- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm
+++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
@@ -88,14 +88,15 @@ sub admin_stats {
my %councils =
map {
- $c->stash->{council_details}->{$_}->{name} =~ s/(?:Borough|City) Council//;
- $_ => $c->stash->{council_details}->{$_}
+ my $name = $_->name;
+ $name =~ s/(?:Borough|City) Council//;
+ ($_->id => $name);
}
- @{ $self->council_id };
+ $c->model('DB::Body')->search({ id => $self->council_id });
$c->stash->{council_details} = \%councils;
- if ( !$c->user_exists || !grep { $_ == $c->user->from_council } @{ $self->council_id } ) {
+ if ( !$c->user_exists || !grep { $_ == $c->user->from_body->id } @{ $self->council_id } ) {
$c->detach( '/page_error_404_not_found' );
}
@@ -123,7 +124,7 @@ sub admin_stats {
},
{
columns => [ qw(
- service category subcategory council confirmed
+ service category subcategory confirmed bodies_str
) ],
order_by => { -desc=> [ 'confirmed' ] },
rows => 20,