source: trunk/lib/Vote/Controller/Newpoll.pm @ 167

Last change on this file since 167 was 128, checked in by nanardon, 15 years ago
  • code is now under PERL License and CeCILL
File size: 1.4 KB
Line 
1package Vote::Controller::Newpoll;
2
3use strict;
4use warnings;
5use base 'Catalyst::Controller';
6
7=head1 NAME
8
9Vote::Controller::Newpoll - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub begin : Private {
25    my ( $self, $c ) = @_;
26    $c->model('Vote')->db->rollback;
27}
28
29sub index : Private {
30    my ( $self, $c ) = @_;
31
32    $c->stash->{page}{title} = 'Créer un nouveau vote';
33    if ($c->req->param('mail')) {
34        $c->model('Vote')->create_poll_request(
35            mail => $c->req->param('mail'),
36            url => $c->uri_for('/newpoll'),
37            label => $c->req->param('label'),
38        );
39        $c->stash->{template} = 'newpoll/request.tt';
40    }
41
42}
43
44sub default : LocalPath {
45    my ( $self, $c, undef, $id ) = @_;
46
47    $c->stash->{reqid} = $id;
48
49    if (!$c->model('Vote')->poll_request_info($id)) {
50        $c->stash->{page}{title} = "Aucune requête de création de vote";
51        $c->stash->{template} = 'newpoll/norequest.tt';
52        return;
53    }
54
55    $c->stash->{page}{title} = 'Confirmer la création d\'un nouveau vote';
56    if ($c->req->param('passwd')) {
57        my $pid = $c->model('Vote')->poll_from_request($id, $c->req->param('passwd'));
58        $c->res->redirect($c->uri_for('/admin', $pid));
59    }
60}
61
62=head1 AUTHOR
63
64Thauvin Olivier
65
66=head1 LICENSE
67
68This library is free software, you can redistribute it and/or modify
69it under the same terms as Perl itself or CeCILL.
70
71=cut
72
731;
Note: See TracBrowser for help on using the repository browser.