diff options
author | Struan Donald <struan@exo.org.uk> | 2018-10-15 12:09:53 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-10-19 14:31:45 +0100 |
commit | 00db75c5734b3bd6229599e741622b25405c3b9c (patch) | |
tree | 93e27afb7b07c63dcf8d3cfbb98a0b0b46eda7c1 /perllib/FixMyStreet/App/Controller/Admin.pm | |
parent | 39b2948d786aaa528adbd7afb2ff6a5cbdb541cd (diff) |
list user's alerts on user edit page in admin
Include a list of alerts the user is subscribed to at the bottom of the
user_edit page in the admin.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 8ccc5b8d3..e13a4b7ca 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -1512,6 +1512,10 @@ sub user_edit : Path('user_edit') : Args(1) { $c->forward('fetch_all_bodies'); $c->forward('fetch_body_areas', [ $user->from_body ]) if $user->from_body; + unless ( $c->cobrand->moniker eq 'zurich' ) { + $c->forward('user_alert_details'); + } + if ( defined $c->flash->{status_message} ) { $c->stash->{status_message} = '<p><em>' . $c->flash->{status_message} . '</em></p>'; @@ -1847,6 +1851,28 @@ sub get_user : Private { return $user; } +sub user_alert_details : Private { + my ( $self, $c ) = @_; + + my @alerts = $c->stash->{user}->alerts({}, { prefetch => 'alert_type' })->all; + $c->stash->{alerts} = \@alerts; + + my @wards; + + for my $alert (@alerts) { + if ($alert->alert_type->ref eq 'ward_problems') { + push @wards, $alert->parameter2; + } + } + + if (@wards) { + $c->stash->{alert_areas} = mySociety::MaPit::call('areas', join(',', @wards) ); + } + + my %body_names = map { $_->{id} => $_->{name} } @{ $c->stash->{bodies} }; + $c->stash->{body_names} = \%body_names; +} + =item log_edit $c->forward( 'log_edit', [ $object_id, $object_type, $action_performed ] ); |