From b6c9d7fcca0e2d77216c6d877c9de3c037d1f22b Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 15 Feb 2006 12:22:58 +0000 Subject: * migliorata formattazione delle date * escape di HTML su tutti i campi (evita XSS) * corretta gestione unicode (accentate nei nomi) git-svn-id: svn://luxion/repos/IscrittiGroLUG/trunk@194 fcb26f47-9200-0410-b104-b98ab5b095f3 --- GroLUG/lib/GroLUG.pm | 8 +++++++- GroLUG/lib/GroLUG/C/Iscritto.pm | 24 +++++++++--------------- GroLUG/lib/GroLUG/M/DB.pm | 2 +- GroLUG/lib/GroLUG/M/DB/Iscritto.pm | 2 +- GroLUG/root/src/lista-iscritti.tt2 | 4 ++-- GroLUG/root/src/message.tt2 | 16 ---------------- GroLUG/root/src/scheda-iscritto.tt2 | 6 +++--- GroLUG/root/src/welcome.tt2 | 9 --------- 8 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 GroLUG/root/src/message.tt2 delete mode 100644 GroLUG/root/src/welcome.tt2 diff --git a/GroLUG/lib/GroLUG.pm b/GroLUG/lib/GroLUG.pm index f7c7751..bfc7986 100644 --- a/GroLUG/lib/GroLUG.pm +++ b/GroLUG/lib/GroLUG.pm @@ -7,7 +7,7 @@ use Catalyst qw{ Session Session::Store::DBI Session::State::Cookie Authentication Authentication::Store::Htpasswd Authentication::Credential::Password Authorization::Roles - HTML::Widget + HTML::Widget Unicode }; use Catalyst::Log::Log4perl; @@ -28,4 +28,10 @@ sub index : Private { } } +sub strdate { + my ($self,$date)=@_; + + return (ref $date) ? $date->strftime('%F') : ''; +} + 1; diff --git a/GroLUG/lib/GroLUG/C/Iscritto.pm b/GroLUG/lib/GroLUG/C/Iscritto.pm index 20cb5c2..b2a9609 100644 --- a/GroLUG/lib/GroLUG/C/Iscritto.pm +++ b/GroLUG/lib/GroLUG/C/Iscritto.pm @@ -52,9 +52,9 @@ sub widget_for_iscr { $widget->filter('TrimEdges','nome','email','note'); - $widget->constraint('All','nome','email'); - $widget->constraint('Email','email'); - $widget->constraint('Printable','nome'); + $widget->constraint('All','nome','email')->message('Campo obbligatorio'); + $widget->constraint('Email','email')->message('Indirizzo malformato'); + $widget->constraint('Printable','nome')->message('Caratteri non validi nel nome'); $widget->indicator('email'); @@ -121,12 +121,6 @@ sub attiva :Local { $c->res->redirect($c->uri_for('scheda',$id)); } -sub strdate { - my ($date)=@_; - - return (defined $date ? $date->strftime('%F') : ''); -} - sub widget_for_pag { my ($self,$c,$pag,$iscr_id)=@_; @@ -138,9 +132,9 @@ sub widget_for_pag { my $widget=$c->widget('pagamento'); $widget->method('post'); - $widget->element('Textfield','data_pagamento')->label('Data del pagamento')->value(strdate($pagamento->data_pagamento)); - $widget->element('Textfield','data_iscrizione')->label('Data di iscrizione')->value(strdate($pagamento->data_iscrizione)); - $widget->element('Textfield','data_scadenza')->label('Data di scadenza')->value(strdate($pagamento->data_scadenza)); + $widget->element('Textfield','data_pagamento')->label('Data del pagamento')->value($self->strdate($pagamento->data_pagamento)); + $widget->element('Textfield','data_iscrizione')->label('Data di iscrizione')->value($self->strdate($pagamento->data_iscrizione)); + $widget->element('Textfield','data_scadenza')->label('Data di scadenza')->value($self->strdate($pagamento->data_scadenza)); $widget->element('Textfield','prezzo')->label('Importo pagato')->value($pagamento->prezzo); $widget->element('Hidden','iscr_id')->value($iscr_id || (defined $pag ? $pagamento->iscritto->id : '')); @@ -148,9 +142,9 @@ sub widget_for_pag { $widget->filter('TrimEdges','data_scadenza','data_pagamento','data_iscrizione','prezzo'); - $widget->constraint('All','data_scadenza','data_pagamento','data_iscrizione','prezzo'); - $widget->constraint('ISODate','data_scadenza','data_pagamento','data_iscrizione'); - $widget->constraint('EuroAmount','prezzo'); + $widget->constraint('All','data_scadenza','data_pagamento','data_iscrizione','prezzo')->messagge('Campo obbligatorio'); + $widget->constraint('ISODate','data_scadenza','data_pagamento','data_iscrizione')->message('Data non valida'); + $widget->constraint('EuroAmount','prezzo')->message('Prezzo non valido'); $widget->indicator('iscr_id'); diff --git a/GroLUG/lib/GroLUG/M/DB.pm b/GroLUG/lib/GroLUG/M/DB.pm index 2622de2..42d6d15 100644 --- a/GroLUG/lib/GroLUG/M/DB.pm +++ b/GroLUG/lib/GroLUG/M/DB.pm @@ -7,7 +7,7 @@ my @conn_info = ( 'dbi:Pg:dbname=iscritti', 'grolug', '', - { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel => 0 } + { RaiseError => 1, PrintError => 0, ShowErrorStatement => 1, TraceLevel => 0, pg_enable_utf8 => 1 } ); __PACKAGE__->load_classes(); diff --git a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm index 1cea0ac..b4a091d 100644 --- a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm +++ b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm @@ -11,7 +11,7 @@ sub scadenza { my ($self)=@_; my $last_pag=$self->pagamenti()->next(); - return ($last_pag ? $last_pag->data_scadenza() : undef); + return $last_pag ? $last_pag->data_scadenza() : undef; } 1; diff --git a/GroLUG/root/src/lista-iscritti.tt2 b/GroLUG/root/src/lista-iscritti.tt2 index 9618520..27b93de 100644 --- a/GroLUG/root/src/lista-iscritti.tt2 +++ b/GroLUG/root/src/lista-iscritti.tt2 @@ -3,8 +3,8 @@
    [% WHILE (iscr = iscritti.next()) %]
  1. - [% iscr.nome %] - scade: [% iscr.scadenza %] + [% iscr.nome | html %] + scade: [% Catalyst.strdate(iscr.scadenza) %] rinnova
  2. [% END %] diff --git a/GroLUG/root/src/message.tt2 b/GroLUG/root/src/message.tt2 deleted file mode 100644 index e72a468..0000000 --- a/GroLUG/root/src/message.tt2 +++ /dev/null @@ -1,16 +0,0 @@ -[% META title = 'Catalyst/TT View!' %] -

    - Yay! You're looking at a page generated by the Catalyst::View::TT - plugin module. -

    -

    - We have a message for you: [% message %]. -

    -

    - Why not try updating the message? Go on, it's really exciting, honest! -

    -
    - - -
    diff --git a/GroLUG/root/src/scheda-iscritto.tt2 b/GroLUG/root/src/scheda-iscritto.tt2 index 835b22a..9dab32e 100644 --- a/GroLUG/root/src/scheda-iscritto.tt2 +++ b/GroLUG/root/src/scheda-iscritto.tt2 @@ -1,4 +1,4 @@ -

    Scheda di [% iscritto.nome %]

    +

    Scheda di [% iscritto.nome | html %]

    Operazioni:

    Indirizzo:
    [% iscritto.email %]
    -
    Note:
    [% iscritto.note %]
    +
    Note:
    [% iscritto.note | html %]
    Pagamenti:
      [%- FOREACH pag IN iscritto.pagamenti %] -
    1. [% pag.prezzo %] il [% pag.data_pagamento %] edit elimina
    2. +
    3. [% pag.prezzo %] il [% Catalyst.strdate(pag.data_pagamento) %] edit elimina
    4. [% END -%]
    diff --git a/GroLUG/root/src/welcome.tt2 b/GroLUG/root/src/welcome.tt2 deleted file mode 100644 index 26f3d89..0000000 --- a/GroLUG/root/src/welcome.tt2 +++ /dev/null @@ -1,9 +0,0 @@ -[% META title = 'Catalyst/TT View!' %] -

    - Yay! You're looking at a page generated by the Catalyst::View::TT - plugin module. -

    -

    - This is the welcome page. Why not try the equally-exciting - Message Page? -

    -- cgit v1.2.3