- Timestamp:
- 03/14/09 18:49:17 (15 years ago)
- Location:
- trunk/lib/Vote
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Controller/Admin.pm
r28 r29 30 30 my ( $self, $c, undef, $id ) = @_; 31 31 $c->stash->{voteid} = $id; 32 my $vote = $c->model('Vote'); 32 33 33 # can't modify vote after date 34 if ($c->model('Vote')->vote_status($id) ne 'BEFORE') { 34 if ($vote->vote_status($id) eq 'BEFORE') { 35 if (my ($upload) = $c->req->upload('votinglist')) { 36 $vote->voting_from_file( 37 $id, 38 $upload->fh, 39 $c->req->param('delete'), 40 ) and $vote->db->commit; 41 } elsif ($c->req->param('addch')) { 42 $vote->vote_add_choice($id, $c->req->param('addch')) 43 and $vote->db->commit; 44 } elsif ($c->req->param('delch')) { 45 $vote->delete_choice($c->req->param('delch')) 46 and $vote->db->commit; 47 } elsif ($c->req->param('label')) { 48 $vote->vote_param( 49 $id, 50 map { $_ => ($c->req->param($_) || undef) } 51 qw(label description start end choice_count free_choice) 52 ) and $vote->db->commit; 53 } elsif($c->req->param('delvoting')) { 54 $vote->delete_voting($c->req->param('delvoting')) 55 and $vote->db->commit; 56 } elsif ($c->req->param('mail')) { 57 $vote->addupd_voting($id, $c->req->param('id'), $c->req->param('mail')) 58 and $vote->db->commit; 59 } elsif($c->req->param('mailpasswd')) { 60 $vote->mail_passwd_ifnul($id); 61 } 62 } elsif ($vote->vote_status($id) eq 'AFTER') { 63 foreach my $bid ($vote->list_vote_ballot_needvalid($id)) { 64 if (!$c->req->param($bid)) { 65 next; 66 } elsif($c->req->param($bid) eq 'invalid') { 67 $vote->mark_ballot_invalid($bid, 1); 68 $vote->db->commit; 69 } elsif($c->req->param($bid) eq 'valid') { 70 $vote->mark_ballot_invalid($bid, 0); 71 $vote->db->commit; 72 } 73 } 74 } else { 75 # can't modify vote after date 35 76 $c->stash->{template} = 'admin/denied.tt'; 36 77 return; 37 78 } 38 79 39 my $vote = $c->model('Vote');40 if (my ($upload) = $c->req->upload('votinglist')) {41 $vote->voting_from_file(42 $id,43 $upload->fh,44 $c->req->param('delete'),45 ) and $vote->db->commit;46 } elsif ($c->req->param('addch')) {47 $vote->vote_add_choice($id, $c->req->param('addch'))48 and $vote->db->commit;49 } elsif ($c->req->param('delch')) {50 $vote->delete_choice($c->req->param('delch'))51 and $vote->db->commit;52 } elsif ($c->req->param('label')) {53 $vote->vote_param(54 $id,55 map { $_ => ($c->req->param($_) || undef) }56 qw(label description start end choice_count free_choice)57 ) and $vote->db->commit;58 } elsif($c->req->param('delvoting')) {59 $vote->delete_voting($c->req->param('delvoting'))60 and $vote->db->commit;61 } elsif ($c->req->param('mail')) {62 $vote->addupd_voting($id, $c->req->param('id'), $c->req->param('mail'))63 and $vote->db->commit;64 } elsif($c->req->param('mailpasswd')) {65 $vote->mail_passwd_ifnul($id);66 }67 80 } 68 81 -
trunk/lib/Vote/Model/Vote.pm
r28 r29 574 574 } 575 575 576 sub mark_ballot_invalid { 577 my ($self, $ballotid, $invalid) = @_; 578 579 my $sth = $self->db->prepare_cached( 580 q{update ballot set invalid = ? where id = ?} 581 ); 582 583 $sth->execute($invalid ? 't' : 'f', $ballotid); 584 } 585 576 586 sub ballot_items { 577 587 my ($self, $ballotid) = @_;
Note: See TracChangeset
for help on using the changeset viewer.