diff --git a/Web/lib/MJB/Web/Controller/Admin.pm b/Web/lib/MJB/Web/Controller/Admin.pm index 332bfd9..ae8e536 100644 --- a/Web/lib/MJB/Web/Controller/Admin.pm +++ b/Web/lib/MJB/Web/Controller/Admin.pm @@ -301,6 +301,16 @@ sub do_sync_ssl ( $c ) { return $c->redirect_success( 'show_admin_jobs', 'Scheduled job to sync SSL certs.' ); } +#== +# GET /admin/alerts | show_admin_alerts +# +# This route shows alerts that have been send through the system_notes table +#== +sub alerts ( $c ) { + push @{$c->stash->{alerts}}, + $c->db->system_notes( { }, { order_by => { -desc => 'created_at' } } )->all; +} + #== # POST /admin/alert/read | do_admin_alert_read # nid | The ID for the system_note diff --git a/Web/t/01_endpoints/01_admin/15_alerts.t b/Web/t/01_endpoints/01_admin/15_alerts.t index abae63b..e88e300 100644 --- a/Web/t/01_endpoints/01_admin/15_alerts.t +++ b/Web/t/01_endpoints/01_admin/15_alerts.t @@ -43,6 +43,10 @@ $t->post_ok( '/register/open', form => { # Check that we have an alert about the account that has just been created, $t->get_ok( '/admin/alerts' ) - ->content_like( qr|An account was created for fred\@blog.com|, 'We have an alert for the user account created!' ); + ->code_block( sub { + my $self = shift; + is $self->stash->{alerts}->[0]->content, 'An account was created for fred@blog.com', + 'We have an alert for the user account created!'; + }); done_testing(); diff --git a/Web/templates/admin/alerts.html.ep b/Web/templates/admin/alerts.html.ep index 3a62368..79a5d23 100644 --- a/Web/templates/admin/alerts.html.ep +++ b/Web/templates/admin/alerts.html.ep @@ -4,7 +4,7 @@ %= include '_base/status_window'; -% for my $alert ( $c->db->system_notes( { }, { order_by => { -desc => 'created_at' } } )->all ) { +% for my $alert ( @{$c->stash->{alerts}} ) {
% if ( $alert->is_read == 1 ) {