[Catalyst-commits] r10626 - in trunk/Catalyst-Example-InstantCRUD:
. lib/Catalyst/Example/Controller lib/Catalyst/Helper/View
script t t/var
zby at dev.catalyst.perl.org
zby at dev.catalyst.perl.org
Tue Jun 23 19:54:38 GMT 2009
Author: zby
Date: 2009-06-23 19:54:38 +0000 (Tue, 23 Jun 2009)
New Revision: 10626
Modified:
trunk/Catalyst-Example-InstantCRUD/MANIFEST
trunk/Catalyst-Example-InstantCRUD/Makefile.PL
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/View/InstantCRUD.pm
trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl
trunk/Catalyst-Example-InstantCRUD/t/00.createapp.t
trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t
trunk/Catalyst-Example-InstantCRUD/t/21.test_dvdzbr.t
trunk/Catalyst-Example-InstantCRUD/t/var/test.sql
Log:
small fixes
Modified: trunk/Catalyst-Example-InstantCRUD/MANIFEST
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/MANIFEST 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/MANIFEST 2009-06-23 19:54:38 UTC (rev 10626)
@@ -12,9 +12,8 @@
t/31.test_rest.t
t/pod-coverage.t
t/pod.t
+t/var/test.sql
t/tmp/test.db
-t/var/dvdzbr.db
-t/var/test.db
lib/Catalyst/Helper/View/InstantCRUD.pm
lib/Catalyst/Helper/Model/InstantCRUD.pm
lib/Catalyst/Helper/InstantCRUD.pm
@@ -22,5 +21,5 @@
lib/Catalyst/Plugin/Auth/Utils.pm
lib/Catalyst/Example/InstantCRUD.pm
lib/Catalyst/Example/Controller/InstantCRUD.pm
-b/Catalyst/Example/Controller/InstantCRUD/REST.pm
+lib/Catalyst/Example/Controller/InstantCRUD/REST.pm
META.yml Module meta-data (added by MakeMaker)
Modified: trunk/Catalyst-Example-InstantCRUD/Makefile.PL
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/Makefile.PL 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/Makefile.PL 2009-06-23 19:54:38 UTC (rev 10626)
@@ -28,8 +28,7 @@
# 'Catalyst::Plugin::Authentication::Credential::Password' => 0,
'Catalyst::Plugin::Session::State::Cookie' => 0,
'Catalyst::Plugin::Session::Store::FastMmap' => 0,
- 'Rose::HTMLx::Form::DBIC' => 0.08,
- 'Rose::HTMLx::Form::DBIC::FormGenerator' => 0,
+ 'HTML::FormHandler::Generator::DBIC' => 0.02,
'Path::Class' => 0,
# 'version' => 0,
# 'URI::Escape' => 0,
Modified: trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm 2009-06-23 19:54:38 UTC (rev 10626)
@@ -83,15 +83,13 @@
@ids = ( item_id => [ @pks ] ) if @pks;
my $form = $form_name->new(
schema => $self->model_schema($c),
-# item_class => $self->source_name($c),
- method => $c->req->method,
params => $c->req->params,
@ids,
);
- if( $form->process() ){
+ if( $c->req->method eq 'POST' && $form->process() ){
my $item = $form->item;
- $c->res->redirect( $c->uri_for( 'view', $item->id ) );
- $c->stash( item => $item );
+ $c->res->redirect( $c->uri_for( 'view', $item->id ) );
+ $c->stash( item => $item );
}
if( @pks ){
$form->field( 'submit' )->value( 'Update' );
@@ -108,7 +106,6 @@
die "You need to pass an id" unless @pks;
my $item = $self->model_item( $c, @pks );
$c->stash->{item} = $item;
-# $c->stash->{template} = 'view.tt';
}
sub get_resultset {
@@ -156,7 +153,6 @@
($c->stash->{pri}) = $source->primary_columns;
$c->stash->{order_by_column_link} = $self->create_col_link($c, $source);
$c->stash->{result} = $result;
-# $c->stash->{template} = 'list.tt';
}
Modified: trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/View/InstantCRUD.pm
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/View/InstantCRUD.pm 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/View/InstantCRUD.pm 2009-06-23 19:54:38 UTC (rev 10626)
@@ -197,15 +197,20 @@
__view__
[% TAGS <+ +> %]
+<table name="view">
<+ FOR column = field_configs +>
-<b><+ column.label +>:</b>
+<tr>
+<td class="view_label"><b><+ column.label +>:</b></td>
+<td>
<+ IF column.multiple +>
[% FOR val = item.<+ column.name +>; val; ', '; END %]
<+ ELSE +>
[% item.<+ column.name +> %]
<+ END +>
- <br/>
+</td>
+</tr>
<+ END +>
+</table>
<hr />
<a href="[% c.uri_for( 'edit', <+ FOR key = primary_keys +>item.<+ key +>, <+ END +> ) %]">Edit</a>
<hr />
@@ -282,7 +287,7 @@
This is the restricted area - available only after loggin in.
__home__
This is an application generated by
-<a href="http://search.cpan.org/~zby/Catalyst-Example-InstantCRUD-v0.0.9/lib/Catalyst/Example/InstantCRUD.pm">Catalyst::Example::InstantCRUD</a>
+<a href="http://search.cpan.org/dist/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/InstantCRUD.pm">Catalyst::Example::InstantCRUD</a>
- a generator of simple database applications for the
<a href="http://catalyst.perl.org">Catalyst</a> framework.
See also
Modified: trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl 2009-06-23 19:54:38 UTC (rev 10626)
@@ -76,13 +76,20 @@
'rest' => $rest,
} );
+my $appdir = $appname;
+$appdir =~ s/::/-/g;
+if( -d $appdir ){
+ warn "\nThe directory '$appdir' already exists! Cannot recreate '$appname'!\n\n";
+ pod2usage(1);
+ exit;
+}
+
if( ! $helper->mk_app( $appname ) ){
warn "Cannot create application: $appname\n";
- pod2usage(1) unless $helper->mk_app( $appname );
+ pod2usage(1);
+ exit;
}
-my $appdir = $appname;
-$appdir =~ s/::/-/g;
if( ! $dsn ){
my $db_file = lc $appname . '.db';
$db_file =~ s/::/_/g;
@@ -102,7 +109,7 @@
dump_directory => dir( $appdir , 'lib')->absolute->stringify,
use_namespaces => 1,
# default_resultset_class => '+DBIx::Class::ResultSet::RecursiveUpdate',
- components => 'UTF8Columns',
+ components => [ 'InflateColumn::DateTime', 'UTF8Columns' ],
},
[ $dsn, $duser, $dpassword ],
);
@@ -237,7 +244,9 @@
-model_name model name (default: DBICSchemamodel)
-schema_name schema name (default: DBSchema)
- ApplicationName must be a valid Perl module name and can include "::";
+ ApplicationName must be a valid Perl module name and can include "::".
+ This version cannot update previously generated code base - it can only
+ generate a new one.
All options are optional, if no dsn is provided an example SQLite database will be
created and used.
@@ -351,7 +360,7 @@
name VARCHAR(255) DEFAULT NULL,
imdb_id INTEGER DEFAULT NULL,
owner INTEGER NOT NULL REFERENCES user (id),
- current_owner INTEGER DEFAULT NULL REFERENCES user (id),
+ current_borrower INTEGER DEFAULT NULL REFERENCES user (id),
creation_date date DEFAULT NULL,
alter_date datetime DEFAULT NULL,
hour time DEFAULT NULL
@@ -420,7 +429,7 @@
name VARCHAR(255) DEFAULT NULL
);
INSERT INTO "user" VALUES(1,'jgda','35a2c6fae61f8077aab61faa4019722abf05093c','Jonas Alves');
-INSERT INTO "user" VALUES(2,'isa','59dc310530b44e8dd1231682b4cc5f2458af1c60','Isa');
+INSERT INTO "user" VALUES(2,'maya','59dc310530b44e8dd1231682b4cc5f2458af1c60','Maya');
CREATE TABLE user_role (
user INTEGER NOT NULL DEFAULT '0' REFERENCES user (id),
role INTEGER NOT NULL DEFAULT '0' REFERENCES role (id),
Modified: trunk/Catalyst-Example-InstantCRUD/t/00.createapp.t
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/t/00.createapp.t 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/t/00.createapp.t 2009-06-23 19:54:38 UTC (rev 10626)
@@ -3,17 +3,16 @@
use Test::More tests => 2;
use Path::Class;
use File::Path;
-use File::Copy;
+use DBI;
my $apptree = dir('t', 'tmp', 'My-App');
my $dbfile = file('t', 'tmp', 'test.db');
rmtree( [$apptree, $dbfile] );
my $testfile = file('t', 'tmp', 'test.db')->absolute->stringify;
-my $origtestfile = file('t', 'var', 'test.db')->absolute->stringify;
+my $sqlfile = file('t', 'var', 'test.sql')->absolute->stringify;
+create_example_db( $testfile, $sqlfile );
-copy $origtestfile, $testfile;
-
my $tmpdir = dir(qw/ t tmp/);
my $libdir = dir(dir()->parent->parent, 'lib');
my $instant = file(dir()->parent->parent, 'script', 'instantcrud.pl');
@@ -28,3 +27,24 @@
ok( -f file(qw/ t tmp My-App lib My App DBSchema.pm/), 'DBSchema creation');
ok( -f file( qw/ t tmp My-App lib My App Controller Usr.pm / ), 'Controller for "User" created');
+sub create_example_db {
+ my ( $filename, $sqlfile ) = @_;
+ my $dsn ||= 'dbi:SQLite:dbname=' . $filename;
+ my $dbh = DBI->connect( $dsn ) or die "Cannot connect to $dsn\n";
+ $dbh->{unicode} = 1;
+
+ my $sqlfh;
+ open $sqlfh, $sqlfile;
+ my $sql;
+ {
+ local $/;
+ $sql = <$sqlfh>;
+ }
+
+ for my $statement ( split /;/, $sql ){
+ next if $statement =~ /\A\s*\z/;
+# warn "executing: \n$statement";
+ $dbh->do($statement) or die $dbh->errstr;
+ }
+}
+
Modified: trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t 2009-06-23 19:54:38 UTC (rev 10626)
@@ -12,7 +12,7 @@
if ($@){
plan skip_all => "Test::WWW::Mechanize::Catalyst required for testing application";
}else{
- plan tests => 20;
+ plan tests => 22;
}
my $mech = Test::WWW::Mechanize::Catalyst->new;
@@ -56,8 +56,8 @@
value => 'Varchar Field',
}
);
-$mech->content_like( qr{<b>Id1:</b>\s*$id1\s*<br/>}, 'Viewing record with composed key' );
-$mech->follow_link_ok({text => 'Edit'}, "Editing a DVD");
+$mech->content_like( qr{<b>Id1:</b></td>\s*<td>\s*$id1}, 'Viewing record with composed key' );
+$mech->follow_link_ok({text => 'Edit'}, "Editing a record with composed key");
$mech->content_contains( $id1, 'Following Edit for a record with composed key' );
my $random_string = 'random ' . random_regex('\w{20}');
#DBI->trace(1);
@@ -69,4 +69,6 @@
);
$mech->content_contains( $id1, 'Editing record with composed key' );
$mech->content_contains( $random_string, 'Editing record with composed key' );
+$mech->follow_link_ok({text => 'List'}, "Listing records with composed key");
+$mech->content_contains( $random_string, 'Listing of records with composed key contains the new record' );
Modified: trunk/Catalyst-Example-InstantCRUD/t/21.test_dvdzbr.t
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/t/21.test_dvdzbr.t 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/t/21.test_dvdzbr.t 2009-06-23 19:54:38 UTC (rev 10626)
@@ -107,8 +107,12 @@
owner => 1,
current_owner => 2,
hour => '10:00',
- creation_date => '1990/08/23',
- alter_date => '2000/02/17',
+ 'creation_date.year' => '1990',
+ 'creation_date.month' => '08',
+ 'creation_date.day' => '23',
+ 'alter_date.year' => '2000',
+ 'alter_date.month' => '02',
+ 'alter_date.day' => '17',
imdb_id => 133,
}
);
@@ -128,8 +132,12 @@
owner => 1,
current_owner => 2,
hour => '10:00',
- creation_date => '1990/08/23',
- alter_date => '2000/02/17',
+ 'creation_date.year' => '1990',
+ 'creation_date.month' => '08',
+ 'creation_date.day' => '23',
+ 'alter_date.year' => '2000',
+ 'alter_date.month' => '02',
+ 'alter_date.day' => '17',
imdb_id => 133,
}
);
Modified: trunk/Catalyst-Example-InstantCRUD/t/var/test.sql
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/t/var/test.sql 2009-06-23 19:54:29 UTC (rev 10625)
+++ trunk/Catalyst-Example-InstantCRUD/t/var/test.sql 2009-06-23 19:54:38 UTC (rev 10626)
@@ -61,6 +61,6 @@
value varchar(32),
primary key (id1, id2)
);
-INSERT INTO "composed_key" VALUES(0,0,'bbb');
+INSERT INTO "composed_key" VALUES(1,1,'bbb');
COMMIT;
More information about the Catalyst-commits
mailing list