Changeset 206 for trunk/lib/Vote/Controller/Admin.pm
- Timestamp:
- 04/16/09 00:16:56 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Controller/Admin.pm
r205 r206 37 37 my $id = $c->stash->{voteid}; 38 38 39 my $vote = $c->model('Vote');40 39 my $poll = $c->model('Vote')->poll($id); 41 40 for ($poll->status || '') { 42 41 /^BEFORE$/ and do { 43 42 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; 46 45 } 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; 49 48 } elsif ($c->req->param('pollparam')) { 50 49 if ($c->req->param('dstart')) { … … 59 58 } 60 59 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'))) { 63 62 $c->stash->{dateerror} = "Le vote se termine avant de commencer"; 64 63 next; … … 76 75 grep { exists($c->req->params->{$_}) } 77 76 qw(label description start end choice_count free_choice) 78 ) and $ vote->commit;77 ) and $poll->commit; 79 78 } elsif ($c->req->param('encrypted')) { 80 79 my $passphrase = $c->req->param('passphrase') || 81 80 $c->session->{'vpass' . $c->stash->{voteid}}; 82 81 $poll->gen_poll_keys($passphrase) 83 and $ vote->commit;82 and $poll->commit; 84 83 } elsif ($c->req->param('notcrypted')) { 85 84 $poll->param(public_key => undef, private_key => undef) 86 and $ vote->commit;85 and $poll->commit; 87 86 } 88 87 }; … … 90 89 /^(BEFORE|RUNNING)$/ and do { 91 90 if (my ($upload) = $c->req->upload('votinglist')) { 92 $vote->voting_from_file( 93 $id, 91 $poll->voting_from_file( 94 92 $upload->fh, 95 93 $c->req->param('delete'), 96 ) and $ vote->commit;94 ) and $poll->commit; 97 95 } 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; 100 98 } 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; 103 101 } elsif($c->req->param('mailpasswd')) { 104 102 # TODO … … 125 123 /^AFTER$/ and do { 126 124 if ($c->req->param('mapfrom') && $c->req->param('mapto')) { 127 $ vote->vote_map_value(125 $poll->map_value( 128 126 $id, 129 127 $c->req->param('mapfrom'), … … 131 129 ); 132 130 } 133 foreach my $bid ($ vote->list_vote_ballot_needvalid($id)) {131 foreach my $bid ($poll->list_ballot_needvalid) { 134 132 if (!$c->req->param($bid)) { 135 133 next; 136 134 } 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; 139 137 } 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; 142 140 } 143 141 } … … 160 158 sub auth : Private { 161 159 my ($self, $c) = @_; 162 my $ vote = $c->model('Vote');160 my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 163 161 my $password = $c->session->{'vpass' . $c->stash->{voteid}} || 164 162 $c->req->param('vpass' . $c->stash->{voteid}); 165 163 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'; 170 167 $c->session->{'vpass' . $c->stash->{voteid}} = undef; 171 168 $c->stash->{template} = 'admin/login.tt'; … … 179 176 my ( $self, $c, undef, $id ) = @_; 180 177 $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 { 184 181 $c->res->redirect($c->uri_for('/')); 185 182 return; … … 188 185 $c->forward('auth') or return; 189 186 $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'; 191 188 } 192 189 … … 194 191 my ($self, $c) = @_; 195 192 ($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 { 199 196 $c->res->redirect($c->uri_for('/')); 200 197 return; … … 203 200 $c->forward('auth') or return; 204 201 $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'; 208 203 } 209 204 … … 211 206 my ($self, $c) = @_; 212 207 ($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 { 216 211 $c->res->redirect($c->uri_for('/')); 217 212 return; … … 220 215 $c->forward('auth') or return; 221 216 $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'; 225 218 } 226 219 227 220 sub privatekey : LocalRegex('^(\d+)/privatekey$') { 228 my ($self, $c , $id, @sub) = @_;221 my ($self, $c) = @_; 229 222 ($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') || ''); 237 230 } 238 231
Note: See TracChangeset
for help on using the changeset viewer.