- Timestamp:
- 04/06/09 18:45:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Controller/Admin.pm
r128 r167 23 23 24 24 sub begin : Private { 25 my ( $self, $c ) = @_;25 my ( $self, $c, @args ) = @_; 26 26 $c->model('Vote')->db->rollback; 27 28 warn join('-', @args); 27 29 } 28 30 … … 33 35 } 34 36 35 sub default : Private { 36 my ( $self, $c, undef, $id ) = @_; 37 $c->stash->{voteid} = $id; 37 sub modify_poll : Private { 38 my ( $self, $c) = @_; 39 my $id = $c->stash->{voteid}; 40 38 41 my $vote = $c->model('Vote'); 39 40 $vote->vote_info($id) or do {41 $c->res->redirect($c->uri_for('/'));42 return;43 };44 45 my $password = $c->session->{vpassword} || $c->req->param('vpassword');46 47 if (!$c->model('Vote')->auth_poll($id, $password)) {48 $c->stash->{page}{title} = $vote->vote_info($id)->{label} . ': Login d\'administration';49 $c->session->{vpassword} = undef;50 $c->stash->{template} = 'admin/login.tt';51 return;52 }53 54 $c->session->{vpassword} = $password;55 56 $c->stash->{page}{title} = $c->model('Vote')->vote_info($id)->{label} . ': Administration';57 58 42 for ($vote->vote_status($id) || '') { 59 43 /^BEFORE$/ and do { … … 124 108 }; 125 109 } 110 } 126 111 112 sub auth : Private { 113 my ($self, $c) = @_; 114 my $vote = $c->model('Vote'); 115 my $password = $c->session->{vpassword} || $c->req->param('vpassword'); 116 117 if (!$c->model('Vote')->auth_poll($c->stash->{voteid}, $password)) { 118 $c->stash->{page}{title} = $vote->vote_info( 119 $c->stash->{voteid} 120 )->{label} . ': Login d\'administration'; 121 $c->session->{vpassword} = undef; 122 $c->stash->{template} = 'admin/login.tt'; 123 return; 124 } 125 $c->session->{vpassword} = $password; 126 return 1; 127 } 128 129 sub default : Private { 130 my ( $self, $c, undef, $id ) = @_; 131 $c->stash->{voteid} = $id; 132 my $vote = $c->model('Vote'); 133 134 $vote->vote_info($id) or do { 135 $c->res->redirect($c->uri_for('/')); 136 return; 137 }; 138 139 $c->forward('auth') or return; 140 $c->forward('modify_poll'); 141 $c->stash->{page}{title} = $c->model('Vote')->vote_info($id)->{label} . ': Administration'; 142 143 144 } 145 146 sub voting: LocalRegex('^(\d+)/voting$') { 147 my ($self, $c, $id, @sub) = @_; 148 ($c->stash->{voteid}) = @{ $c->req->snippets || [] }; 149 my $vote = $c->model('Vote'); 150 151 $vote->vote_info($id) or do { 152 $c->res->redirect($c->uri_for('/')); 153 return; 154 }; 155 156 $c->forward('auth') or return; 157 $c->forward('modify_poll'); 158 $c->stash->{page}{title} = $c->model('Vote')->vote_info($id)->{label} . ': Administration'; 127 159 } 128 160
Note: See TracChangeset
for help on using the changeset viewer.