diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index c05fafb..1c5efd6 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -177,6 +177,9 @@ sub startup { $admin_routes->get('/organisations/pending/:id')->to('admin-organisations#pending_read'); $admin_routes->get('/organisations/pending/:id/approve')->to('admin-organisations#pending_approve'); + $admin_routes->get('/feedback')->to('admin-feedback#index'); + $admin_routes->get('/feedback/:id')->to('admin-feedback#read'); + # my $user_routes = $r->under('/')->to('root#under'); # $user_routes->get('/home')->to('root#home'); diff --git a/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm b/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm new file mode 100644 index 0000000..f9063a4 --- /dev/null +++ b/lib/Pear/LocalLoop/Controller/Admin/Feedback.pm @@ -0,0 +1,29 @@ +package Pear::LocalLoop::Controller::Admin::Feedback; +use Mojo::Base 'Mojolicious::Controller'; + +has result_set => sub { + my $c = shift; + return $c->schema->resultset('Feedback'); +}; + +sub index { + my $c = shift; + + my $feedback_rs = $c->result_set; + $c->stash( feedbacks => [ $feedback_rs->all ] ); +} + +sub read { + my $c = shift; + + my $id = $c->param('id'); + + if ( my $feedback = $c->result_set->find($id) ) { + $c->stash( feedback => $feedback ); + } else { + $c->flash( error => 'No Feedback found' ); + $c->redirect_to( '/admin/feedback' ); + } +} + +1; diff --git a/lib/Pear/LocalLoop/Controller/Api/Feedback.pm b/lib/Pear/LocalLoop/Controller/Api/Feedback.pm index 34f1bf2..eafce88 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Feedback.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Feedback.pm @@ -45,7 +45,6 @@ sub post_feedback { my $user = $user_rs->find({'email' => $validation->param('email')}); $c->schema->resultset('Feedback')->create({ - email => $validation->param('email'), user => $user, feedbacktext => $validation->param('feedbacktext'), app_name => $validation->param('app_name'), diff --git a/lib/Pear/LocalLoop/Schema/Result/Feedback.pm b/lib/Pear/LocalLoop/Schema/Result/Feedback.pm index 60deba9..2d741ae 100644 --- a/lib/Pear/LocalLoop/Schema/Result/Feedback.pm +++ b/lib/Pear/LocalLoop/Schema/Result/Feedback.pm @@ -7,18 +7,24 @@ use base 'DBIx::Class::Core'; __PACKAGE__->table("feedback"); +__PACKAGE__->load_components(qw/ + InflateColumn::DateTime + TimeStamp +/); + __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, - "email" => { - data_type => "text", - is_nullable => 0, - }, "user_id" => { data_type => "integer", is_foreign_key => 1, is_nullable => 0, }, + "submitted_at" => { + data_type => "datetime", + is_nullable => 0, + set_on_create => 1, + }, "feedbacktext" => { data_type => "text", is_nullable => 0, diff --git a/templates/admin/feedback/index.html.ep b/templates/admin/feedback/index.html.ep new file mode 100644 index 0000000..375ed5a --- /dev/null +++ b/templates/admin/feedback/index.html.ep @@ -0,0 +1,25 @@ +% layout 'admin'; +% title 'Feedback'; +% content_for javascript => begin +% end +% if ( my $error = flash 'error' ) { +