Changeset 315 for trunk/lib/Epoll/Controller
- Timestamp:
- 05/23/10 19:51:07 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Epoll/Controller/Admin.pm
r301 r315 100 100 }; 101 101 102 /^(BEFORE|RUNNING)$/ and do {103 if (my ($upload) = $c->req->upload('votinglist')) {104 $poll->voting_from_file(105 $upload->fh,106 $c->req->param('delete'),107 ) and $poll->commit;108 } elsif($c->req->param('delvoting')) {109 $poll->delete_voting($c->req->param('delvoting'))110 and $poll->commit;111 } elsif ($c->req->param('mail')) {112 $poll->addupd_voting($c->req->param('mail'), $c->req->param('id'))113 and $poll->commit;114 } elsif($c->req->param('mailpasswd')) {115 # TODO116 foreach my $vkey ($poll->list_voting_no_passwd) {117 my $voting = $poll->voting($vkey);118 my $pass = $voting->gen_passwd;119 $c->forward(120 q'Epoll::View::Mail', 'render',121 [ 'voting_passwd.tt', {122 From => $poll->info->{owner},123 To => $voting->info->{mail},124 Subject => "Invitation à voter",125 mail => {126 voteid => $id,127 mail => $voting->info->{mail},128 passwd => $pass,129 }130 } ]131 );132 }133 }134 };135 136 102 /^AFTER$/ and do { 137 103 if ($c->req->param('mapfrom')) { … … 224 190 my ($self, $c) = @_; 225 191 ($c->stash->{voteid}) = @{ $c->req->snippets || [] }; 226 my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 227 228 $poll->info or do { 229 $c->res->redirect($c->uri_for('/')); 230 return; 231 }; 232 233 $c->forward('auth') or return; 234 $c->forward('modify_poll'); 192 my $id = $c->stash->{voteid}; 193 my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 194 195 $poll->info or do { 196 $c->res->redirect($c->uri_for('/')); 197 return; 198 }; 199 200 $c->forward('auth') or return; 201 202 for ($poll->status || '') { 203 /^(BEFORE|RUNNING)$/ and do { 204 if($c->req->param('delvoting')) { 205 $poll->delete_voting($c->req->param('delvoting')) 206 and $poll->commit; 207 } elsif ($c->req->param('mail')) { 208 $poll->addupd_voting($c->req->param('mail'), $c->req->param('id')) 209 and $poll->commit; 210 } elsif($c->req->param('mailpasswd')) { 211 # TODO 212 foreach my $vkey ($poll->list_voting_no_passwd) { 213 my $voting = $poll->voting($vkey); 214 my $pass = $voting->gen_passwd; 215 $c->forward( 216 q'Epoll::View::Mail', 'render', 217 [ 'voting_passwd.tt', { 218 From => $poll->info->{owner}, 219 To => $voting->info->{mail}, 220 Subject => "Invitation à voter", 221 mail => { 222 voteid => $id, 223 mail => $voting->info->{mail}, 224 passwd => $pass, 225 } 226 } ] 227 ); 228 } 229 } 230 }; 231 } 232 235 233 $c->stash->{page}{title} = $poll->info('label') . ': Administration, liste des electeurs'; 234 } 235 236 sub votersimport: LocalRegex('^(\w+)/voters/import$') { 237 my ($self, $c) = @_; 238 ($c->stash->{voteid}) = @{ $c->req->snippets || [] }; 239 my $poll = $c->model('Vote')->poll($c->stash->{voteid}); 240 241 if ($c->req->param('importtype')) { 242 if (my $handle = $poll->import_handle($c->req->param('importtype'))) { 243 $c->stash->{import_handle} = $handle; 244 if ($c->req->param('add_import')) { 245 warn $c->session->{import_param}; 246 $handle->load_xml_params($c->session->{import_param}); 247 if ($poll->voting_from_import($handle, 248 ext_auth => $c->req->param('ext_auth') || undef, 249 desc => $c->req->param('desc') || undef, 250 )) { 251 $poll->commit; 252 $c->res->redirect($c->uri_for($c->stash->{voteid}, 253 'voters')); 254 return; 255 } 256 } else { 257 $handle->load_web_params($c); 258 } 259 $c->stash->{voters} = [ $handle->fetch_voters() ]; 260 $c->{stash}->{importtt} = 'importv/' . 261 lc($c->req->param('importtype')) . '.tt'; 262 warn $handle->xml_params; 263 $c->session->{import_param} = $handle->xml_params; 264 } else { 265 warn "Fail to load input handle"; 266 } 267 } 268 236 269 } 237 270
Note: See TracChangeset
for help on using the changeset viewer.