From 1d02854c9613864489f1321ca1eec47bfe24dfc8 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 18 Apr 2017 19:03:03 +0100 Subject: [PATCH] Initial work on Admin users page --- lib/Pear/LocalLoop.pm | 1 - lib/Pear/LocalLoop/Controller/Admin/Users.pm | 18 ++++++------ templates/admin/users/read.html.ep | 30 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 templates/admin/users/read.html.ep diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 55aa9c3..f6fac56 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -110,7 +110,6 @@ sub startup { $admin_routes->post('/tokens/:id')->to('admin-tokens#update'); $admin_routes->post('/tokens/:id/delete')->to('admin-tokens#delete'); $admin_routes->get('/users')->to('admin-users#index'); - $admin_routes->post('/users')->to('admin-users#create'); $admin_routes->get('/users/:id')->to('admin-users#read'); $admin_routes->post('/users/:id')->to('admin-users#update'); $admin_routes->post('/users/:id/delete')->to('admin-users#delete'); diff --git a/lib/Pear/LocalLoop/Controller/Admin/Users.pm b/lib/Pear/LocalLoop/Controller/Admin/Users.pm index 6c0828a..2fbdd17 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Users.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Users.pm @@ -14,20 +14,22 @@ sub index { $c->stash( users => [ $user_rs->all ] ); } -sub create { - my $c = shift; -} - sub read { my $c = shift; + + my $id = $c->param('id'); + + if ( my $user = $c->result_set->find($id) ) { + $c->stash( user => $user ); + } else { + $c->flash( error => 'No User found' ); + $c->redirect_to( '/admin/users' ); + } } sub update { my $c = shift; -} - -sub delete { - my $c = shift; + $c->redirect_to( '/admin/users' ); } 1; diff --git a/templates/admin/users/read.html.ep b/templates/admin/users/read.html.ep new file mode 100644 index 0000000..8002e1b --- /dev/null +++ b/templates/admin/users/read.html.ep @@ -0,0 +1,30 @@ +% layout 'admin'; +% title 'Users'; +% content_for javascript => begin +% end +% if ( my $error = flash 'error' ) { + +% } elsif ( my $success = flash 'success' ) { + +% } +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+