diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 9890811..5a2bcfe 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -191,6 +191,7 @@ sub startup { $admin_routes->get('/feedback')->to('admin-feedback#index'); $admin_routes->get('/feedback/:id')->to('admin-feedback#read'); + $admin_routes->get('/feedback/:id/actioned')->to('admin-feedback#actioned'); $admin_routes->get('/transactions')->to('admin-transactions#index'); $admin_routes->get('/transactions/:id')->to('admin-transactions#read'); diff --git a/lib/Pear/LocalLoop/Controller/Admin.pm b/lib/Pear/LocalLoop/Controller/Admin.pm index 7a9cf8d..1e5a411 100644 --- a/lib/Pear/LocalLoop/Controller/Admin.pm +++ b/lib/Pear/LocalLoop/Controller/Admin.pm @@ -18,6 +18,8 @@ sub home { my $token_rs = $c->schema->resultset('AccountToken'); my $pending_orgs_rs = $c->schema->resultset('Organisation')->search({ pending => 1 }); my $pending_transaction_rs = $pending_orgs_rs->entity->sales; + my $feedback_rs = $c->schema->resultset('Feedback'); + my $pending_feedback_rs = $feedback_rs->search({ actioned => 0 }); $c->stash( user_count => $user_rs->count, tokens => { @@ -26,6 +28,10 @@ sub home { }, pending_orgs => $pending_orgs_rs->count, pending_trans => $pending_transaction_rs->count, + feedback => { + total => $feedback_rs->count, + pending => $pending_feedback_rs->count, + }, ); } diff --git a/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm b/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm index 753539c..a182362 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm @@ -33,4 +33,19 @@ sub read { } } +sub actioned { + my $c = shift; + + my $id = $c->param('id'); + + if ( my $feedback = $c->result_set->find($id) ) { + $feedback->actioned( ! $feedback->actioned ); + $feedback->update; + $c->redirect_to( '/admin/feedback/' . $id ); + } else { + $c->flash( error => 'No Feedback found' ); + $c->redirect_to( '/admin/feedback' ); + } +} + 1; diff --git a/templates/admin/feedback/index.html.ep b/templates/admin/feedback/index.html.ep index 8c41fd4..9c7242a 100644 --- a/templates/admin/feedback/index.html.ep +++ b/templates/admin/feedback/index.html.ep @@ -15,7 +15,7 @@ % for my $feedback ( $feedback_rs->all ) {