Feedback HTML views added and fixes made

This commit is contained in:
Finn 2017-07-24 15:21:10 +01:00
parent baea01e8b5
commit 09f9cf9d48
6 changed files with 110 additions and 5 deletions

View file

@ -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;

View file

@ -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'),

View file

@ -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,