From b2bf6e98e29ba55c41d134a1e640bdaa560d1152 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 8 Feb 2006 18:52:19 +0000 Subject: funge il modello... ca**o git-svn-id: svn://luxion/repos/IscrittiGroLUG/trunk@170 fcb26f47-9200-0410-b104-b98ab5b095f3 --- GroLUG/grolug.yml | 4 +++ GroLUG/lib/GroLUG.pm | 60 +------------------------------------- GroLUG/lib/GroLUG/C/Iscritti.pm | 49 +++++++++++++++++++++++++++++++ GroLUG/lib/GroLUG/M/DB.pm | 27 ++--------------- GroLUG/lib/GroLUG/M/DB/Iscritto.pm | 2 +- GroLUG/sql/crea-tabelle.sql | 9 +++++- GroLUG/t/c_Iscritti.t | 9 ++++++ GroLUG/test_manuali/prova_db.pl | 18 ++++++------ 8 files changed, 83 insertions(+), 95 deletions(-) create mode 100644 GroLUG/lib/GroLUG/C/Iscritti.pm create mode 100644 GroLUG/t/c_Iscritti.t (limited to 'GroLUG') diff --git a/GroLUG/grolug.yml b/GroLUG/grolug.yml index 03c89e9..1e1d18e 100644 --- a/GroLUG/grolug.yml +++ b/GroLUG/grolug.yml @@ -1,2 +1,6 @@ --- name: GroLUG +session: + expires: 3600 + dbi_dbh: 'GroLUG::M::DB' + dbi_table: 'sessions' diff --git a/GroLUG/lib/GroLUG.pm b/GroLUG/lib/GroLUG.pm index dca5de0..404fde1 100644 --- a/GroLUG/lib/GroLUG.pm +++ b/GroLUG/lib/GroLUG.pm @@ -3,45 +3,12 @@ package GroLUG; use strict; use warnings; -# -# Set flags and add plugins for the application -# -# -Debug: activates the debug mode for very useful log messages -# Static::Simple: will serve static files from the application's root -# directory -# -use Catalyst qw/-Debug ConfigLoader Static::Simple/; +use Catalyst qw/-Debug ConfigLoader Static::Simple DefaultEnd Session Session::Store::DBI Session::State::Cookie/; our $VERSION = '0.01'; -# -# Start the application -# __PACKAGE__->setup; -=head1 NAME - -GroLUG - Catalyst based application - -=head1 SYNOPSIS - - script/grolug_server.pl - -=head1 DESCRIPTION - -Catalyst based application. - -=head1 METHODS - -=cut - -=head2 default - -=cut - -# -# Output a friendly welcome message -# sub default : Private { my ( $self, $c ) = @_; @@ -49,29 +16,4 @@ sub default : Private { $c->response->body( $c->welcome_message ); } -# -# Uncomment and modify this end action after adding a View component -# -#=head2 end -# -#=cut -# -#sub end : Private { -# my ( $self, $c ) = @_; -# -# # Forward to View unless response body is already defined -# $c->forward( $c->view('') ) unless $c->response->body; -#} - -=head1 AUTHOR - -Catalyst developer - -=head1 LICENSE - -This library is free software, you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut - 1; diff --git a/GroLUG/lib/GroLUG/C/Iscritti.pm b/GroLUG/lib/GroLUG/C/Iscritti.pm new file mode 100644 index 0000000..d79aea6 --- /dev/null +++ b/GroLUG/lib/GroLUG/C/Iscritti.pm @@ -0,0 +1,49 @@ +package GroLUG::C::Iscritti; + +use strict; +use warnings; +use base 'Catalyst::Controller'; + +=head1 NAME + +GroLUG::C::Iscritti - Catalyst Controller + +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + +# +# Uncomment and modify this or add new actions to fit your needs +# +#=head2 default +# +#=cut +# +#sub default : Private { +# my ( $self, $c ) = @_; +# +# # Hello World +# $c->response->body('GroLUG::C::Iscritti is on Catalyst!'); +#} + + +=head1 AUTHOR + +A clever guy + +=head1 LICENSE + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +1; diff --git a/GroLUG/lib/GroLUG/M/DB.pm b/GroLUG/lib/GroLUG/M/DB.pm index 193cb7a..2622de2 100644 --- a/GroLUG/lib/GroLUG/M/DB.pm +++ b/GroLUG/lib/GroLUG/M/DB.pm @@ -10,31 +10,8 @@ my @conn_info = ( { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel => 0 } ); -__PACKAGE__->load_classes; -#DBIx::Class::Schema->compose_connection( __PACKAGE__, @conn_info ); - -=head1 NAME - -GroLUG::M::DB - DBIC Plain Model Component - -=head1 SYNOPSIS - -See L - -=head1 DESCRIPTION - -DBIC Plain Model Component. - -=head1 AUTHOR - -A clever guy - -=head1 LICENSE - -This library is free software . You can redistribute it and/or modify -it under the same terms as perl itself. - -=cut +__PACKAGE__->load_classes(); +__PACKAGE__->compose_connection(__PACKAGE__,@conn_info); 1; diff --git a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm index 5ae0d33..686b4b2 100644 --- a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm +++ b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm @@ -5,6 +5,6 @@ __PACKAGE__->load_components(qw(PK::Auto::Pg)); __PACKAGE__->table('iscritti'); __PACKAGE__->add_columns(qw(id nome email attivo note)); __PACKAGE__->set_primary_key('id'); -__PACKAGE__->has_many(pagamenti=>'GroLUG::M::DB::Pagamento','iscritto'); +__PACKAGE__->has_many(pagamenti=>'GroLUG::M::DB::Pagamento','iscritto',{order_by => 'data_scadenza desc'}); 1; diff --git a/GroLUG/sql/crea-tabelle.sql b/GroLUG/sql/crea-tabelle.sql index 6d88509..802c95a 100644 --- a/GroLUG/sql/crea-tabelle.sql +++ b/GroLUG/sql/crea-tabelle.sql @@ -1,5 +1,12 @@ -drop table iscritti; drop table pagamenti; +drop table iscritti; +drop table sessioni; + +create table sessioni ( + id char(72) primary key, + session_data text, + expires int +); create table iscritti ( id serial primary key, diff --git a/GroLUG/t/c_Iscritti.t b/GroLUG/t/c_Iscritti.t new file mode 100644 index 0000000..7cc006c --- /dev/null +++ b/GroLUG/t/c_Iscritti.t @@ -0,0 +1,9 @@ +use strict; +use warnings; + +use Test::More tests => 3; +use_ok( 'Catalyst::Test', 'GroLUG' ); +use_ok('GroLUG::C::Iscritti'); + +ok( request('iscritti')->is_success, 'Request should succeed' ); + diff --git a/GroLUG/test_manuali/prova_db.pl b/GroLUG/test_manuali/prova_db.pl index 0a3849d..ffa0cf8 100644 --- a/GroLUG/test_manuali/prova_db.pl +++ b/GroLUG/test_manuali/prova_db.pl @@ -6,13 +6,13 @@ use DateTime; #use Devel::TraceCalls;trace_calls { Package => [qw(DBIx::Class::Schema DBIx::Class::Storage::DBI)]}; -my $schema=GroLUG::M::DB->connect('dbi:Pg:dbname=iscritti', - 'grolug', - '', - { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel => 0 }); +# my $schema=GroLUG::M::DB->connect('dbi:Pg:dbname=iscritti', +# 'grolug', +# '', +# { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel => 0 }); { -my $iscritto=$schema->resultset('Iscritto')->create({ +my $iscritto=GroLUG::M::DB->resultset('Iscritto')->create({ nome => '__tizio', email => 'tizio@qui', }); @@ -31,10 +31,10 @@ $iscritto->add_to_pagamenti({ } -my $iscritto=$schema->resultset('Iscritto')->search({email=>'tizio@qui'})->next();; +my $iscritto=GroLUG::M::DB->resultset('Iscritto')->search({email=>'tizio@qui'})->next();; -my $last_pag=$iscritto->pagamenti({},{order_by => 'data_scadenza desc'})->next(); +my $last_pag=$iscritto->pagamenti()->next(); print 'Prossima scadenza: ',$last_pag->data_scadenza(),"\n"; -$schema->resultset('Pagamento')->delete(); -$schema->resultset('Iscritto')->delete(); +GroLUG::M::DB->resultset('Pagamento')->delete(); +GroLUG::M::DB->resultset('Iscritto')->delete(); -- cgit v1.2.3