Vote::Controller::Newpoll - Catalyst Controller


Vote documentation Contained in the Vote distribution.

Index


Code Index:

NAME

Top

Vote::Controller::Newpoll - Catalyst Controller

DESCRIPTION

Top

Catalyst Controller.

METHODS

Top

index

AUTHOR

Top

Thauvin Olivier

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself or CeCILL.


Vote documentation Contained in the Vote distribution.
package Vote::Controller::Newpoll;

use strict;
use warnings;
use base 'Catalyst::Controller';

sub begin : Private {
    my ( $self, $c ) = @_;
    $c->model('Vote')->db->rollback;
}

sub index : Private {
    my ( $self, $c ) = @_;

    $c->stash->{page}{title} = 'Créer un nouveau vote';
    if ($c->req->param('mail')) {
        $c->model('Vote')->create_poll_request(
            mail => $c->req->param('mail'),
            url => $c->uri_for('/newpoll'),
            label => $c->req->param('label'),
        );
        $c->stash->{template} = 'newpoll/request.tt';
    }

}

sub default : LocalPath {
    my ( $self, $c, undef, $id ) = @_;

    $c->stash->{reqid} = $id;

    if (!$c->model('Vote')->poll_request_info($id)) {
        $c->stash->{page}{title} = "Aucune requête de création de vote";
        $c->stash->{template} = 'newpoll/norequest.tt';
        return;
    }

    $c->stash->{page}{title} = 'Confirmer la création d\'un nouveau vote';
    if ($c->req->param('passwd')) {
        my $pid = $c->model('Vote')->poll_from_request($id, $c->req->param('passwd'));
        $c->res->redirect($c->uri_for('/admin', $pid));
    }
}

1;