source: trunk/lib/Vote/Controller/Admin.pm @ 23

Last change on this file since 23 was 23, checked in by nanardon, 15 years ago
  • admin page is fully working
File size: 1.7 KB
Line 
1package Vote::Controller::Admin;
2
3use strict;
4use warnings;
5use base 'Catalyst::Controller';
6
7=head1 NAME
8
9Vote::Controller::Admin - 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 index : Private {
25    my ( $self, $c ) = @_;
26
27}
28
29sub default : Private {
30    my ( $self, $c, undef, $id ) = @_;
31    $c->stash->{voteid} = $id;
32
33    # can't modify vote after date
34    if ($c->model('Vote')->vote_status($id) ne 'BEFORE') {
35        $c->stash->{template} = 'admin/denied.tt';
36        return;
37    }
38
39    my $vote = $c->model('Vote');
40    if (my ($upload) = $c->req->upload('votinglist')) {
41        $vote->voting_from_file(
42            $id,
43            $upload->fh,
44            $c->req->param('delete'),
45        ) and $vote->db->commit;
46    } elsif ($c->req->param('addch')) {
47        $vote->vote_add_choice($id, $c->req->param('addch'))
48            and $vote->db->commit;
49    } elsif ($c->req->param('delch')) {
50        $vote->delete_choice($c->req->param('delch'))
51            and $vote->db->commit;
52    } elsif ($c->req->param('label')) {
53        $vote->vote_param(
54            $id,
55            map { $_ => ($c->req->param($_) || undef) }
56            qw(label description start end choice_count free_choice)
57        ) and $vote->db->commit;
58    } elsif($c->req->param('delvoting')) {
59        $vote->delete_voting($c->req->param('delvoting'))
60            and $vote->db->commit;
61    } elsif ($c->req->param('mail')) {
62        $vote->addupd_voting($id, $c->req->param('id'), $c->req->param('mail'))
63            and $vote->db->commit;
64    }
65}
66
67=head1 AUTHOR
68
69Thauvin Olivier
70
71=head1 LICENSE
72
73This library is free software, you can redistribute it and/or modify
74it under the same terms as Perl itself.
75
76=cut
77
781;
Note: See TracBrowser for help on using the repository browser.