summaryrefslogtreecommitdiff
path: root/GroLUG
diff options
context:
space:
mode:
Diffstat (limited to 'GroLUG')
-rw-r--r--GroLUG/lib/GroLUG/M/DB/Iscritto.pm2
-rw-r--r--GroLUG/sql/crea-tabelle.sql1
-rw-r--r--GroLUG/test_manuali/prova_db.pl19
3 files changed, 19 insertions, 3 deletions
diff --git a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm
index 32282f5..5ae0d33 100644
--- a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm
+++ b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm
@@ -3,7 +3,7 @@ use base 'DBIx::Class::Core';
__PACKAGE__->load_components(qw(PK::Auto::Pg));
__PACKAGE__->table('iscritti');
-__PACKAGE__->add_columns(qw(id nome email note));
+__PACKAGE__->add_columns(qw(id nome email attivo note));
__PACKAGE__->set_primary_key('id');
__PACKAGE__->has_many(pagamenti=>'GroLUG::M::DB::Pagamento','iscritto');
diff --git a/GroLUG/sql/crea-tabelle.sql b/GroLUG/sql/crea-tabelle.sql
index 6e57d95..6d88509 100644
--- a/GroLUG/sql/crea-tabelle.sql
+++ b/GroLUG/sql/crea-tabelle.sql
@@ -5,6 +5,7 @@ create table iscritti (
id serial primary key,
nome varchar(255) not null,
email varchar(255) unique not null,
+ attivo boolean default true,
note text
);
diff --git a/GroLUG/test_manuali/prova_db.pl b/GroLUG/test_manuali/prova_db.pl
index fcfc7bc..0a3849d 100644
--- a/GroLUG/test_manuali/prova_db.pl
+++ b/GroLUG/test_manuali/prova_db.pl
@@ -11,7 +11,8 @@ my $schema=GroLUG::M::DB->connect('dbi:Pg:dbname=iscritti',
'',
{ RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel => 0 });
-my $iscritto=$schema->resultset('GroLUG::M::DB::Iscritto')->create({
+{
+my $iscritto=$schema->resultset('Iscritto')->create({
nome => '__tizio',
email => 'tizio@qui',
});
@@ -22,4 +23,18 @@ $iscritto->add_to_pagamenti({
data_scadenza=>DateTime->now()->subtract(days=>10)->add(years=>1),
prezzo=>50});
-$schema->commit();
+$iscritto->add_to_pagamenti({
+ data_pagamento=>DateTime->now()->subtract(years=>1),
+ data_iscrizione=>DateTime->now()->subtract(years=>1,days=>22),
+ data_scadenza=>DateTime->now()->subtract(days=>11),
+ prezzo=>50});
+
+}
+
+my $iscritto=$schema->resultset('Iscritto')->search({email=>'tizio@qui'})->next();;
+
+my $last_pag=$iscritto->pagamenti({},{order_by => 'data_scadenza desc'})->next();
+print 'Prossima scadenza: ',$last_pag->data_scadenza(),"\n";
+
+$schema->resultset('Pagamento')->delete();
+$schema->resultset('Iscritto')->delete();