Ignore:
Timestamp:
04/16/09 00:16:56 (15 years ago)
Author:
nanardon
Message:
  • kill some old function usage
File:
1 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 
Note: See TracChangeset for help on using the changeset viewer.