sub base : Chained('/'): PathPart('admin'): CaptureArgs(0) { my ($self, $c) = @_; $c->stash( users_rs => $c->model('DB::Tech')); $c->log->debug('*** INSIDE BASE METHOD ***'); } sub list :Chained('base') :PathPart('list') :Args(0) { my ($self, $c) = @_; my ($users) = $c->model('DB::Tech')->search_rs; $c->stash( users => $users ); $c->stash(template => 'admin/list.tt2'); $c->log->debug("*** INSIDE LIST METHOD users = $users ***"); } sub create : Chained('base'): PathPart('create'): Args(0) { my ($self, $c) = @_; if(lc $c->req->method eq 'post') { # Retrieve the values fro mthe form my $params = $c->req->params; my $users_rs = $c->stash->{users_rs}; my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime time; $year += 1900; my @month_abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my $date = "$year-$month_abbr[$mon]-$mday"; my $newuser = eval { $users_rs->create({ username => $params->{username}, password => $params->{password}, fname => $params->{fname}, lname => $params->{lname}, email => $params->{email}, phone => $params->{phone}, managementrating => '5', managementcomments => q[], date => $date, ismanagement => '0', }) }; if($@) { $c->log->debug( "Invalid email address in user creation" ); $c->stash->{error_msg} = 'Invalid email address in user creation'; return; } $Data::Dumper::Useperl = 1; } } #### [info] *** Request 1 (0.167/s) [19733] [Tue Mar 29 20:49:35 2011] *** [debug] "GET" request for "admin/list" from "192.168.1.3" [debug] Path is "/admin/list" [debug] *** INSIDE BASE METHOD *** [debug] *** INSIDE LIST METHOD users = 1 *** [debug] Rendering template "admin/list.tt2" [debug] Response Code: 200; Content-Type: text/html; charset=utf-8; Content-Length: 1546 [info] Request took 0.131545s (7.602/s) #### [% META title = 'System Users List' -%] [% FOR tech IN users.all -%] [% END -%]
IDfirstnamelastnameemailphoneManagement RatingCommentsDateAdmin
[% users.id %] [% users.firstname %] [% users.lastname %] [% users.phone %] [% users.email %] [% users.phone %] [% users.managementrating %] [% users.managementcomments %] [% users.date %] [% users.ismanagement %]
Dump of the 'users' variable:
[% Dumper.dump(users) %]