Changeset 206


Ignore:
Timestamp:
04/16/09 00:16:56 (15 years ago)
Author:
nanardon
Message:
  • kill some old function usage
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/Controller/Admin.pm

    r205 r206  
    3737    my $id = $c->stash->{voteid}; 
    3838 
    39     my $vote = $c->model('Vote'); 
    4039    my $poll = $c->model('Vote')->poll($id); 
    4140    for ($poll->status || '') { 
    4241    /^BEFORE$/ and do { 
    4342        if ($c->req->param('addch')) { 
    44             $vote->vote_add_choice($id, $c->req->param('addch')) 
    45                 and $vote->commit; 
     43            $poll->add_choice($c->req->param('addch')) 
     44                and $poll->commit; 
    4645        } elsif ($c->req->param('delch')) { 
    47             $vote->delete_choice($c->req->param('delch')) 
    48                 and $vote->commit; 
     46            $poll->delete_choice($c->req->param('delch')) 
     47                and $poll->commit; 
    4948        } elsif ($c->req->param('pollparam')) { 
    5049            if ($c->req->param('dstart')) { 
     
    5958            } 
    6059            if ($c->req->param('end') && $c->req->param('start')) { 
    61                 if ($vote->check_date_max($c->req->param('start'))) { 
    62                     if (! $vote->check_date_max($c->req->param('end'), $c->req->param('start'))) { 
     60                if ($poll->check_date_max($c->req->param('start'))) { 
     61                    if (! $poll->check_date_max($c->req->param('end'), $c->req->param('start'))) { 
    6362                        $c->stash->{dateerror} = "Le vote se termine avant de commencer"; 
    6463                        next; 
     
    7675                grep { exists($c->req->params->{$_}) } 
    7776                qw(label description start end choice_count free_choice) 
    78             ) and $vote->commit; 
     77            ) and $poll->commit; 
    7978        } elsif ($c->req->param('encrypted')) { 
    8079            my $passphrase = $c->req->param('passphrase') || 
    8180                $c->session->{'vpass' . $c->stash->{voteid}}; 
    8281            $poll->gen_poll_keys($passphrase) 
    83                 and $vote->commit; 
     82                and $poll->commit; 
    8483        } elsif ($c->req->param('notcrypted')) { 
    8584            $poll->param(public_key => undef, private_key => undef) 
    86                 and $vote->commit; 
     85                and $poll->commit; 
    8786        } 
    8887    }; 
     
    9089    /^(BEFORE|RUNNING)$/ and do { 
    9190        if (my ($upload) = $c->req->upload('votinglist')) { 
    92             $vote->voting_from_file( 
    93                 $id, 
     91            $poll->voting_from_file( 
    9492                $upload->fh, 
    9593                $c->req->param('delete'), 
    96             ) and $vote->commit; 
     94            ) and $poll->commit; 
    9795        } elsif($c->req->param('delvoting')) { 
    98             $vote->delete_voting($c->req->param('delvoting')) 
    99                 and $vote->commit; 
     96            $poll->delete_voting($c->req->param('delvoting')) 
     97                and $poll->commit; 
    10098        } elsif ($c->req->param('mail')) { 
    101             $vote->addupd_voting($id, $c->req->param('mail'), $c->req->param('id')) 
    102                 and $vote->commit; 
     99            $poll->addupd_voting($c->req->param('mail'), $c->req->param('id')) 
     100                and $poll->commit; 
    103101        } elsif($c->req->param('mailpasswd')) { 
    104102            # TODO 
     
    125123    /^AFTER$/ and do { 
    126124        if ($c->req->param('mapfrom') && $c->req->param('mapto')) { 
    127             $vote->vote_map_value( 
     125            $poll->map_value( 
    128126                $id, 
    129127                $c->req->param('mapfrom'), 
     
    131129            ); 
    132130        } 
    133         foreach my $bid ($vote->list_vote_ballot_needvalid($id)) { 
     131        foreach my $bid ($poll->list_ballot_needvalid) { 
    134132            if (!$c->req->param($bid)) { 
    135133                next; 
    136134            } elsif($c->req->param($bid) eq 'invalid') { 
    137                 $vote->mark_ballot_invalid($bid, 1); 
    138                 $vote->commit; 
     135                $poll->ballot($bid)->mark_invalid(1); 
     136                $poll->commit; 
    139137            } elsif($c->req->param($bid) eq 'valid') { 
    140                 $vote->mark_ballot_invalid($bid, 0); 
    141                 $vote->commit; 
     138                $poll->ballot($bid)->mark_invalid(0); 
     139                $poll->commit; 
    142140            } 
    143141        } 
     
    160158sub auth : Private { 
    161159    my ($self, $c) = @_; 
    162     my $vote = $c->model('Vote'); 
     160    my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 
    163161    my $password = $c->session->{'vpass' . $c->stash->{voteid}} || 
    164162        $c->req->param('vpass' . $c->stash->{voteid}); 
    165163 
    166     if (!$c->model('Vote')->auth_poll($c->stash->{voteid}, $password)) { 
    167         $c->stash->{page}{title} = $vote->vote_info( 
    168             $c->stash->{voteid} 
    169         )->{label} . ': Login d\'administration'; 
     164    if (!$poll->auth_poll($password)) { 
     165        $c->stash->{page}{title} = $poll->info('label') . 
     166            ': Login d\'administration'; 
    170167        $c->session->{'vpass' . $c->stash->{voteid}} = undef; 
    171168        $c->stash->{template} = 'admin/login.tt'; 
     
    179176    my ( $self, $c, undef, $id ) = @_; 
    180177    $c->stash->{voteid} = $id; 
    181     my $vote = $c->model('Vote'); 
    182  
    183     $vote->vote_info($id) or do { 
     178    my $poll = $c->model('Vote')->poll($id); 
     179 
     180    $poll->info or do { 
    184181        $c->res->redirect($c->uri_for('/')); 
    185182        return; 
     
    188185    $c->forward('auth') or return; 
    189186    $c->forward('modify_poll'); 
    190     $c->stash->{page}{title} = $c->model('Vote')->vote_info($id)->{label} . ': Administration'; 
     187    $c->stash->{page}{title} = $poll->info('label') . ': Administration'; 
    191188} 
    192189 
     
    194191    my ($self, $c) = @_; 
    195192    ($c->stash->{voteid}) = @{ $c->req->snippets || [] }; 
    196     my $vote = $c->model('Vote'); 
    197  
    198     $vote->vote_info($c->stash->{voteid}) or do { 
     193    my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 
     194 
     195    $poll->info or do { 
    199196        $c->res->redirect($c->uri_for('/')); 
    200197        return; 
     
    203200    $c->forward('auth') or return; 
    204201    $c->forward('modify_poll'); 
    205     $c->stash->{page}{title} = $c->model('Vote')->vote_info( 
    206         $c->stash->{voteid} 
    207     )->{label} . ': Administration, liste des electeurs'; 
     202    $c->stash->{page}{title} = $poll->info('label') . ': Administration, liste des electeurs'; 
    208203} 
    209204 
     
    211206    my ($self, $c) = @_; 
    212207    ($c->stash->{voteid}) = @{ $c->req->snippets || [] }; 
    213     my $vote = $c->model('Vote'); 
    214  
    215     $vote->vote_info($c->stash->{voteid}) or do { 
     208    my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 
     209 
     210    $poll->info or do { 
    216211        $c->res->redirect($c->uri_for('/')); 
    217212        return; 
     
    220215    $c->forward('auth') or return; 
    221216    $c->forward('modify_poll'); 
    222     $c->stash->{page}{title} = $c->model('Vote')->vote_info( 
    223         $c->stash->{voteid} 
    224     )->{label} . ': Administration, bulletin'; 
     217    $c->stash->{page}{title} = $poll->info('label') . ': Administration, bulletin'; 
    225218} 
    226219 
    227220sub privatekey : LocalRegex('^(\d+)/privatekey$') { 
    228     my ($self, $c, $id, @sub) = @_; 
     221    my ($self, $c) = @_; 
    229222    ($c->stash->{voteid}) = @{ $c->req->snippets || [] }; 
    230     my $vote = $c->model('Vote'); 
    231  
    232     $vote->vote_info($id) or do { 
    233         $c->res->redirect($c->uri_for('/')); 
    234         return; 
    235     }; 
    236     $c->response->body($vote->vote_info($c->stash->{voteid})->{private_key} || ''); 
     223    my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 
     224 
     225    $poll->info or do { 
     226        $c->res->redirect($c->uri_for('/')); 
     227        return; 
     228    }; 
     229    $c->response->body($poll->info('private_key') || ''); 
    237230} 
    238231 
  • trunk/lib/Vote/Controller/Ballot.pm

    r205 r206  
    3737 
    3838    $c->stash->{voteid} = $id; 
     39    my $poll = $c->model('Vote')->poll($id); 
    3940 
    40     if ($c->model('Vote')->poll($id)->status ne 'RUNNING') { 
     41    if ($poll->status ne 'RUNNING') { 
    4142        $c->stash->{template} = 'ballot/closed.tt'; 
    4243        return; 
     
    4748 
    4849    if (!$c->model('Vote')->auth_voting($id, $mail, $password)) { 
    49         $c->stash->{page}{title} = $c->model('Vote')->vote_info($id)->{label} . ': Login'; 
     50        $c->stash->{page}{title} = $poll->info('label') . ': Login'; 
    5051        $c->delete_session('invalid user/pass'); 
    5152        $c->stash->{template} = 'ballot/login.tt'; 
     
    5960    $c->session->{password} = $password; 
    6061 
    61     $c->stash->{page}{title} = $c->model('Vote')->vote_info($id)->{label} . ': Bulletin'; 
     62    $c->stash->{page}{title} = $poll->info('label') . ': Bulletin'; 
    6263 
    6364    # login succeed, but those this user has already voted 
    64     if (my $date = $c->model('Vote')->voting_has_sign($id, $mail)) { 
     65    if (my $date = $poll->voting_has_sign($mail)) { 
    6566        $c->stash->{mail} = $c->session->{mail}; 
    6667        $c->stash->{template} = 'ballot/signed.tt'; 
     
    8889 
    8990    if (scalar(@sbalval) + scalar(@{$c->stash->{fsbal} || []}) 
    90         > $vote->vote_info($id)->{choice_count}) { 
     91        > $poll->info('choice_count')) { 
    9192        $c->req->parameters->{'ballot'} = ''; 
    9293        $c->stash->{vote_error} = 'Seulement ' . 
    93             $vote->vote_info($id)->{choice_count} . ' choix possible'; 
     94            $poll->info('choice_count') . ' choix possible'; 
    9495        return; 
    9596    } 
     
    122123                From => $mail, 
    123124                To => $mail, 
    124                 Subject => 'Confirmation de vote: ' . $vote->vote_info($id)->{label}, 
     125                Subject => 'Confirmation de vote: ' . $poll->info('label'), 
    125126                mail => { 
    126127                    ballotid => $c->stash->{ballotid}, 
  • trunk/lib/Vote/Controller/Vote.pm

    r198 r206  
    3838 
    3939    $c->stash->{voteid} = $id; 
    40     $c->stash->{page}{title} = 'Vote: ' . $c->model('Vote')->vote_info($id)->{label}; 
     40    $c->stash->{page}{title} = 'Vote: ' . $c->model('Vote')->poll($id).info('label'); 
    4141} 
    4242 
     
    4747    $c->stash->{template} = 'default.tt'; 
    4848 
    49     $vote->vote_info($c->stash->{voteid}) or do { 
     49    $vote->poll($c->stash->{voteid})->info or do { 
    5050        $c->res->redirect($c->uri_for('/')); 
    5151        return; 
  • trunk/lib/Vote/DB.pm

    r205 r206  
    100100} 
    101101 
     102# TODO 
    102103sub ballot { 
    103104    my ($self, $ballotid) = @_; 
     105    die "# ballot" . join(' ',caller()); 
    104106    # TODO must die, ballot are attached to a poll 
    105107    Vote::DB::Ballot->new($self->{dbstring}, $ballotid); 
     
    120122} 
    121123 
     124# TODO 
    122125sub vote_info { 
    123126    my ($self, $id) = @_; 
     127    die "# vote_info" . join(' ',caller()); 
    124128    $self->poll($id)->info; 
    125129} 
  • trunk/lib/Vote/DB/Poll.pm

    r205 r206  
    143143            my $res = $sth->fetchrow_hashref; 
    144144            $sth->finish; 
    145             return defined($res->{$var}) 
    146                 ? $res->{$var} 
     145            return defined($res->{val}) 
     146                ? $res->{val} 
    147147                : $default->{$var}; 
    148148        } 
  • trunk/root/templates/admin/includes/poll_settings.tt

    r205 r206  
    88<form action="[% c.uri_for(voteid) %]" method="POST"> 
    99 
    10 [% thisvote = vote.vote_info(voteid) %] 
    11  
    12 Label: <input type="text" name="label" value="[% c.req.param('label') || thisvote.label | html %]"> 
     10Label: <input type="text" name="label" value="[% c.req.param('label') || poll.info('label') | html %]"> 
    1311<br> 
    1412Description:<br> 
    15 <textarea name="description" cols="60" rows="4">[% c.req.param('description') || thisvote.description | html %]</textarea> 
     13<textarea name="description" cols="60" rows="4">[% c.req.param('description') || poll.info('description') | html %]</textarea> 
    1614<br> 
    1715<hr> 
     
    2523 
    2624Debut du vote:<br> 
    27 Date: <input type="text" name="dstart" value="[% c.req.param('dstart') || thisvote.dstart | html %]"> 
     25Date: <input type="text" name="dstart" value="[% c.req.param('dstart') || poll.info('dstart') | html %]"> 
    2826<A HREF="#" onClick="cal13.select(document.forms[0].dstart,'anchor13','dd/MM/yyyy'); return false;" TITLE="cal13.select(document.forms[0].dstart,'anchor13','dd/MM/yyyy'); return false;" NAME="anchor13" ID="anchor13">select</A> 
    29 Heure: <input type="text" size=9 name="hstart" value="[% c.req.param('hstart') || thisvote.hstart | html %]"> 
     27Heure: <input type="text" size=9 name="hstart" value="[% c.req.param('hstart') || poll.info('hstart') | html %]"> 
    3028<br> 
    3129Fin du vote:<br> 
    32 Date: <input type="text" name="dend" value="[% c.req.param('dend') || thisvote.dend | html %]"> 
     30Date: <input type="text" name="dend" value="[% c.req.param('dend') || poll.info('dend') | html %]"> 
    3331<A HREF="#" onClick="cal13.select(document.forms[0].dend,'anchor14','dd/MM/yyyy',(document.forms[0].dend.value=='')?document.forms[0].dstart.value:null); return false;" TITLE="cal13.select(document.forms[0].dend,'anchor14','dd/MM/yyyy',(document.forms[0].dend.value=='')?document.forms[0].dstart.value:null); return false;" NAME="anchor14" ID="anchor14">select</A> 
    34 Heure: <input type="text" size=9 name="hend" value="[% c.req.param('hend') || thisvote.hend | html %]"> 
     32Heure: <input type="text" size=9 name="hend" value="[% c.req.param('hend') || poll.info('hend') | html %]"> 
    3533<br> 
    3634<hr> 
  • trunk/root/templates/admin/index.tt

    r47 r206  
    11[% vote = c.model('Vote') %] 
     2[% poll = c.model('Vote').poll('voteid') %] 
    23 
    3 [% FOREACH voteid = vote.list_comming_vote %] 
    4 <a href="[% c.uri_for('/admin', voteid) %]">[% vote.vote_info(voteid).label | html %]</a> 
     4[% FOREACH voteid = c.model('Vote').list_comming_vote %] 
     5<a href="[% c.uri_for('/admin', voteid) %]">[% c.model('Vote').poll('voteid').info('label') | html %]</a> 
    56<br> 
    67[% END %] 
  • trunk/root/templates/admin/login.tt

    r186 r206  
    11<!-- $Id$ --> 
    22[% vote = c.model('Vote') %] 
     3[% poll = c.model('Vote').poll(voteid) %] 
    34 
    45<div id="admin_login" class="login_box"> 
    56<form action="[% c.uri_for('/admin', voteid) %]" method="POST"> 
    6 <p>Acc&egrave;s &agrave; l'interface d'administration du vote <b><i>[% vote.vote_info(voteid).label | html %]</i></b></p> 
     7<p>Acc&egrave;s &agrave; l'interface d'administration du vote <b><i>[% poll.info('label') | html %]</i></b></p> 
    78<p>Veuillez saisir le mot de passe : <input type="password" name="[% 'vpass' _ voteid %]"> 
    89<input type="submit"></p> 
  • trunk/root/templates/ballot/default.tt

    r192 r206  
    11[% vote = c.model('Vote') %] 
    2  
    3 [% thisvote = vote.vote_info(voteid) %] 
     2[% poll = c.model('Vote').poll(voteid) %] 
    43 
    54<div id="ballot" class="ballot"> 
    65<form action="[% c.uri_for(voteid) %]" method="POST"> 
    7 <p><b>Vote: [% thisvote.label | html %]</b></p> 
     6<p><b>Vote: [% poll.info('label') | html %]</b></p> 
    87[% IF c.req.param('ballot') %] 
    98<p>Confirmez votre vote:</p> 
    109[% ELSE %] 
    1110[% IF vote_error %]<p class="alert">Erreur: [% vote_error %]</p>[% END %] 
    12 <p>[% thisvote.description | html | html_line_break %]</p> 
    13 <p>[% thisvote.choice_count %] choix possibles:</p> 
     11<p>[% poll.info('description') | html | html_line_break %]</p> 
     12<p>[% poll.info('choice_count') %] choix possibles:</p> 
    1413[% END %] 
    1514<hr> 
  • trunk/root/templates/ballot/index.tt

    r47 r206  
    11[% vote = c.model('Vote') %] 
     2[% poll = c.model('Vote').poll(voteid) %] 
    23 
    34[% voteids = vote.list_running_vote %] 
     
    67 
    78[% FOREACH voteid = voteids %] 
    8 <a href="[% c.uri_for('/ballot', voteid) %]">[% vote.vote_info(voteid).label | html %]</a> 
     9<a href="[% c.uri_for('/ballot', voteid) %]">[% poll.info('label') | html %]</a> 
    910<br> 
    1011[% END %] 
  • trunk/root/templates/default.tt

    r167 r206  
    1010[% END %] 
    1111<tr> 
    12 <td><lu><li><a href="[% c.uri_for( '/vote', id ) %]">[% vote.vote_info(id).label | html %]</a></lu></td></td> 
     12<td><lu><li><a href="[% c.uri_for( '/vote', id ) %]">[% c.model('Vote').poll(id).info('label') | html %]</a></lu></td></td> 
    1313<td>&gt;<a href="[% c.uri_for( '/ballot', id ) %]"> Voter</a></td> 
    1414</tr> 
     
    2828[% END %] 
    2929<tr> 
    30 <td><lu><li><a href="[% c.uri_for( 'vote', id ) %]">[% vote.vote_info(id).label | html %]</a></li></lu></td> 
     30<td><lu><li><a href="[% c.uri_for( 'vote', id ) %]">[% c.model('Vote').poll(id).info('label') | html %]</a></li></lu></td> 
    3131<td>&gt;<a href="[% c.uri_for( '/admin', id ) %]"> Administrer</a></td> 
    3232</tr> 
     
    4747[% END %] 
    4848<tr> 
    49 <td><lu><li><a href="[% c.uri_for( 'vote', id ) %]">[% vote.vote_info(id).label | html %]</a></lu></td></td> 
     49<td><lu><li><a href="[% c.uri_for( 'vote', id ) %]">[% c.model('Vote').poll(id).info('label') | html %]</a></lu></td></td> 
    5050</tr> 
    5151[% IF loop.last %] 
  • trunk/root/templates/includes/header.tt

    r109 r206  
    1919    [% IF voteid %] 
    2020    :: <a href="[% c.uri_for('/vote', voteid) %]"> 
    21         Votre vote: [% c.model('Vote').vote_info(voteid).label | truncate(40) | html %] 
     21        Votre vote: [% c.model('Vote').poll(voteid).info('label') | truncate(40) | html %] 
    2222    </a> 
    2323    [% END %] 
  • trunk/root/templates/includes/poll.tt

    r126 r206  
    11[% vote = c.model('Vote') %] 
    2 [% thisvote = vote.vote_info(voteid) %] 
     2[% poll = c.model('Vote').poll(voteid) %] 
    33 
    44<div id="poll_summary" class="box" style="clear: both;"> 
    55<div style="float: left; width: 70%;"> 
    6 <p id="poll_label">[% thisvote.label | html %]</p> 
    7 <p>[% thisvote.description | html | html_line_break %]</p> 
    8 [% IF thisvote.dstart && thisvote.dend %] 
    9 <p>Scrutin ouvert du <b>[% thisvote.dstart _ ' ' _ thisvote.hstart | html %]</b> au 
    10 <b>[% thisvote.dend _ ' ' _ thisvote.hend | html %]</b></p> 
     6<p id="poll_label">[% poll.info('label') | html %]</p> 
     7<p>[% poll.info('description') | html | html_line_break %]</p> 
     8[% IF poll.info('dstart') && poll.info('dend') %] 
     9<p>Scrutin ouvert du <b>[% poll.info('dstart') _ ' ' _ poll.info('hstart') | html %]</b> au 
     10<b>[% poll.info('dend') _ ' ' _ poll.info('hend') | html %]</b></p> 
    1111[% END %] 
    12 Ont voté: [% vote.vote_signing_count(voteid) %] / [% vote.vote_voting_count(voteid) %]<br> 
    13 Bulletins: [% vote.vote_ballot_count(voteid) %] 
    14 [% IF vote.vote_signing_count(voteid) != vote.vote_ballot_count(voteid) %] 
     12Ont voté: [% poll.signing_count %] / [% poll.voting_count %]<br> 
     13Bulletins: [% poll.ballot_count %] 
     14[% IF poll.signing_count != poll.ballot_count %] 
    1515<p class="alert">Le nombre de bulletins et le nombre de personnes ayant voté divergent, 
    1616suspicion de tricherie</p> 
    1717[% END %] 
    1818</div> 
    19 [% FOREACH item = vote.vote_choices(voteid) %] 
     19[% FOREACH item = poll.choices %] 
    2020[% IF loop.first %] 
    2121<div style="float: right; width: 20%; top: 0px;" class="box"> 
     
    2323<ol style="padding-left:15px; margin:5px;"> 
    2424[% END %] 
    25 <li>[% vote.choice_info(item).label | html %]</li> 
     25<li>[% poll.choice(item).info.label | html %]</li> 
    2626[% IF loop.last %] 
    2727</ol> 
  • trunk/root/templates/includes/poll_results.tt

    r193 r206  
    1414<p>Resultats:</p> 
    1515[% END %] 
    16 <p>Nombre de choix à retenir: [% vote.vote_info(voteid).choice_count %]</p> 
     16<p>Nombre de choix à retenir: [% poll.info('choice_count') %]</p> 
    1717<p>Participations: [% vote.vote_signing_count(voteid) %] / [% vote.vote_voting_count(voteid) %] 
    1818[% IF vote.vote_voting_count(voteid) %] 
     
    4242    [% # If equality, we keep same color, even we are over resullts %] 
    4343[% mycount = loop.count %] 
    44 [% IF loop.count <= vote.vote_info(voteid).choice_count %] 
     44[% IF loop.count <= poll.info('choice_count') %] 
    4545[% IF res.count >= vote.absolute_majority %] 
    4646[% class = 'majabs' %] 
     
    7878<tr><th>numéro</th><th>Id</th> 
    7979<th>contenu (=> corrigé en) 
    80 [% IF vote.vote_info(voteid).free_choice %] 
     80[% IF poll.info('free_choice') %] 
    8181<br>(*: hors liste) 
    8282[% END %] 
Note: See TracChangeset for help on using the changeset viewer.