Changeset 167 for trunk/lib


Ignore:
Timestamp:
04/06/09 18:45:41 (15 years ago)
Author:
nanardon
Message:
  • split voting admin page in subsection
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/Controller/Admin.pm

    r128 r167  
    2323 
    2424sub begin : Private { 
    25     my ( $self, $c ) = @_; 
     25    my ( $self, $c, @args ) = @_; 
    2626    $c->model('Vote')->db->rollback; 
     27 
     28    warn join('-', @args); 
    2729} 
    2830 
     
    3335} 
    3436 
    35 sub default : Private { 
    36     my ( $self, $c, undef, $id ) = @_; 
    37     $c->stash->{voteid} = $id; 
     37sub modify_poll : Private { 
     38    my ( $self, $c) = @_; 
     39    my $id = $c->stash->{voteid}; 
     40 
    3841    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  
    5842    for ($vote->vote_status($id) || '') { 
    5943    /^BEFORE$/ and do { 
     
    124108    }; 
    125109    } 
     110} 
    126111 
     112sub 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 
     129sub 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 
     146sub 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'; 
    127159} 
    128160 
Note: See TracChangeset for help on using the changeset viewer.