aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-10-15 16:47:39 +0100
committerStruan Donald <struan@exo.org.uk>2018-10-19 14:31:45 +0100
commitb57df33a0714d6ee6fb897887eb20b0387321afc (patch)
tree7e9eee152f338b084e13c9a8fa7350be6ec05eac /perllib
parent00db75c5734b3bd6229599e741622b25405c3b9c (diff)
add alert editing to user edit page in admin
disable, enable and delete for user alerts on user_edit page
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm30
1 files changed, 26 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index e13a4b7ca..d757cec9a 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -1512,10 +1512,6 @@ 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>';
@@ -1538,6 +1534,8 @@ sub user_edit : Path('user_edit') : Args(1) {
my %args = ( email => $email );
$args{user_id} = $id if $user->email ne $email || !$user->email_verified;
$c->forward('send_login_email', [ \%args ]);
+ } elsif ( $c->get_param('update_alerts') ) {
+ $c->forward('update_alerts');
} elsif ( $c->get_param('submit') ) {
my $edited = 0;
@@ -1717,6 +1715,11 @@ sub user_edit : Path('user_edit') : Args(1) {
$c->stash->{contacts} = \@all_contacts;
}
+ # this goes after in case we've delete any alerts
+ unless ( $c->cobrand->moniker eq 'zurich' ) {
+ $c->forward('user_alert_details');
+ }
+
return 1;
}
@@ -1945,6 +1948,25 @@ sub ban_user : Private {
return 1;
}
+sub update_alerts : Private {
+ my ($self, $c) = @_;
+
+ my $changes;
+ for my $alert ( $c->stash->{user}->alerts ) {
+ my $edit_option = $c->get_param('edit_alert[' . $alert->id . ']');
+ next unless $edit_option;
+ $changes = 1;
+ if ( $edit_option eq 'delete' ) {
+ $alert->delete;
+ } elsif ( $edit_option eq 'disable' ) {
+ $alert->disable;
+ } elsif ( $edit_option eq 'enable' ) {
+ $alert->confirm;
+ }
+ }
+ $c->flash->{status_message} = _("Updated!") if $changes;
+}
+
sub user_logout_everywhere : Private {
my ( $self, $c, $user ) = @_;
my $sessions = $user->get_extra_metadata('sessions');