Changeset 182


Ignore:
Timestamp:
04/11/09 03:55:22 (15 years ago)
Author:
nanardon
Message:
  • use template for mail everywhere (#5)
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r181 r182  
    5858root/mail/poll_request.tt 
    5959root/mail/ballot_confirm.tt 
     60root/mail/voting_passwd.tt 
    6061root/templates/admin/default.tt 
    6162root/templates/admin/denied.tt 
  • trunk/lib/Vote/Controller/Admin.pm

    r176 r182  
    8787                and $vote->db->commit; 
    8888        } elsif($c->req->param('mailpasswd')) { 
    89             $vote->mail_passwd_ifnul($id, { 
    90                 voteurl => $c->uri_for('/ballot', $id), 
    91             }); 
     89            # TODO 
     90            foreach my $vkey ($poll->list_voting_no_passwd) { 
     91                my $voting = $poll->voting($vkey); 
     92                my $pass = $voting->gen_passwd; 
     93                $c->forward( 
     94                    q'Vote::View::Mail', 'render', 
     95                    [ 'voting_passwd.tt', { 
     96                        From => $poll->info->{owner}, 
     97                        To => $voting->info->{mail}, 
     98                        Subject => "Invitation à voter", 
     99                        mail => { 
     100                            voteid => $id, 
     101                            mail => $voting->info->{mail}, 
     102                            passwd => $pass, 
     103                        } 
     104                    } ] 
     105                ); 
     106            } 
    92107        } 
    93108    }; 
  • trunk/lib/Vote/DB.pm

    r181 r182  
    286286} 
    287287 
    288 sub mail_passwd_ifnul { 
    289     my ($self, $voteid, $mailinfo) = @_; 
    290     $self->poll($voteid)->mail_passwd_ifnul($mailinfo); 
    291 } 
    292  
    293288sub clean_old_poll_request { 
    294289    my ($self) = @_; 
  • trunk/lib/Vote/DB/Poll.pm

    r181 r182  
    811811} 
    812812 
    813 sub mail_passwd_ifnul { 
    814     my ($self, $mailinfo) = @_; 
     813sub list_voting_no_passwd { 
     814    my ($self) = @_; 
    815815 
    816816    my $list_voting = $self->db->prepare_cached( 
     
    819819 
    820820    $list_voting->execute($self->voteid); 
     821    my @ids; 
    821822    while (my $res = $list_voting->fetchrow_hashref) { 
    822         $self->mail_voting_passwd($res->{key}, $mailinfo); 
    823     } 
     823        push(@ids, $res->{key}); 
     824    } 
     825    @ids 
    824826} 
    825827 
  • trunk/lib/Vote/DB/Voting.pm

    r161 r182  
    55use strict; 
    66use warnings; 
    7 use Mail::Mailer; 
    87use base 'Vote::DB::common'; 
    98use Vote::DB::Poll; 
     
    8281} 
    8382 
    84 sub mail_voting_passwd { 
    85     my ($self, $mailinfo) = @_; 
    86      
    87     my $vinfo = $self->info or return; 
    88     my $voteinfo = $self->poll->info; 
    89     $voteinfo->{description} ||= ""; 
    90  
     83sub gen_passwd { 
     84    my ($self) = @_; 
    9185    my $passwd = Vote::DB::common::random_string(8); 
    9286    my $encpasswd = $self->gen_enc_passwd($passwd); 
    93  
    9487    my $upd_voting = $self->db->prepare_cached( 
    9588        q{update voting set passwd = ? where key = ?} 
     
    9790 
    9891    $upd_voting->execute($encpasswd, $self->votingkey); 
    99  
    100     my $date = $voteinfo->{dstart} && $voteinfo->{dend} 
    101         ? sprintf("\n" . 'Vous pourrez voter entre le %s %s et le %s %s' . "\n", 
    102             $voteinfo->{dstart}, $voteinfo->{hstart}, $voteinfo->{dend}, $voteinfo->{hend}) 
    103         : ''; 
    104  
    105     # TODO complete this properly: 
    106     my $mailer = new Mail::Mailer 'smtp', Server => (Vote->config->{smtp} || 'localhost'); 
    107     $ENV{MAILADDRESS} = $voteinfo->{owner}; 
    108     $mailer->open({ 
    109         From => $voteinfo->{owner}, 
    110         To => $vinfo->{mail}, 
    111         Subject => 'Invitation a voter: ' . $voteinfo->{label}, 
    112         'X-Epoll-poll' => $self->poll->voteid, 
    113         Vote::DB::common::mail_header(), 
    114     }); 
    115     print $mailer <<EOF; 
    116 Vous êtes convié à participer a ce vote: 
    117  
    118 -------- 
    119 $voteinfo->{label} 
    120 -------- 
    121 $voteinfo->{description} 
    122 -------- 
    123  
    124 Ã  l'adresse: 
    125  
    126 $mailinfo->{voteurl} 
    127 $date 
    128  
    129 --  
    130 Votre identifiant est: $vinfo->{mail} 
    131 Votre mot de passe est: $passwd 
    132  
    133 Conservez précieusement ces identifiants, il ne vous seront pas retransmits. 
    134  
    135 Cordialement. 
    136 EOF 
    137     $mailer->close or warn "couldn't send whole message: $!\n"; 
    138  
    13992    $self->db->commit; 
     93    $passwd 
    14094} 
    14195 
Note: See TracChangeset for help on using the changeset viewer.