1 | package Epoll::Controller::Root; |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use base 'Catalyst::Controller'; |
---|
6 | |
---|
7 | # |
---|
8 | # Sets the actions in this controller to be registered with no prefix |
---|
9 | # so they function identically to actions created in MyApp.pm |
---|
10 | # |
---|
11 | __PACKAGE__->config->{namespace} = ''; |
---|
12 | |
---|
13 | =head1 NAME |
---|
14 | |
---|
15 | Epoll::Controller::Root - Root Controller for Epoll |
---|
16 | |
---|
17 | =head1 DESCRIPTION |
---|
18 | |
---|
19 | [enter your description here] |
---|
20 | |
---|
21 | =head1 METHODS |
---|
22 | |
---|
23 | =cut |
---|
24 | |
---|
25 | =head2 default |
---|
26 | |
---|
27 | =cut |
---|
28 | |
---|
29 | sub begin : Private { |
---|
30 | my ( $self, $c ) = @_; |
---|
31 | $c->model('Vote')->rollback; |
---|
32 | } |
---|
33 | |
---|
34 | sub default : Private { |
---|
35 | my ( $self, $c ) = @_; |
---|
36 | $c->stash->{page}{title} = 'Epoll ' . $Epoll::DB::VERSION; |
---|
37 | if ($c->req->param('mailvoting')) { |
---|
38 | my @polls_voting = $c->model('Vote')->find_poll_by_notyet_voting( |
---|
39 | $c->req->param('mailvoting') |
---|
40 | ); |
---|
41 | my @polls_owner = $c->model('Vote')->find_poll_by_owner( |
---|
42 | $c->req->param('mailvoting') |
---|
43 | ); |
---|
44 | |
---|
45 | if (scalar(@polls_voting) || scalar(@polls_owner)) { |
---|
46 | $c->forward( |
---|
47 | q'Epoll::View::Mail', 'render', |
---|
48 | [ 'poll_reminder_voting.tt', { |
---|
49 | To => $c->req->param('mailvoting'), |
---|
50 | Subject => $c->localize('Poll request reminder'), |
---|
51 | mail => { |
---|
52 | label => $c->localize('Poll request reminder'), |
---|
53 | polls_owner => \@polls_owner, |
---|
54 | polls_voting => \@polls_voting, |
---|
55 | }, |
---|
56 | }] |
---|
57 | ); |
---|
58 | $c->stash->{sendvoting} = $c->req->param('mailvoting'); |
---|
59 | } else { |
---|
60 | $c->stash->{novoting} = $c->req->param('mailvoting'); |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | =head2 end |
---|
66 | |
---|
67 | Attempt to render a view, if needed. |
---|
68 | |
---|
69 | =cut |
---|
70 | |
---|
71 | sub end : Private { |
---|
72 | my ($self, $c) = @_; |
---|
73 | if ($c->res->body) { return } |
---|
74 | else { $c->forward(qw/Epoll::View::TT/) } |
---|
75 | } |
---|
76 | |
---|
77 | =head1 AUTHOR |
---|
78 | |
---|
79 | Thauvin Olivier |
---|
80 | |
---|
81 | =head1 LICENSE |
---|
82 | |
---|
83 | This library is free software, you can redistribute it and/or modify |
---|
84 | it under the same terms as Perl itself or CeCILL. |
---|
85 | |
---|
86 | =cut |
---|
87 | |
---|
88 | 1; |
---|