Last change
on this file since 439 was
319,
checked in by nanardon, 14 years ago
|
- support of several poll type
- remove static result storage
|
-
Property svn:keywords set to
Id Rev
|
File size:
1.1 KB
|
Rev | Line | |
---|
[319] | 1 | package Epoll::DB::Poll::BSubmit; |
---|
[219] | 2 | |
---|
| 3 | # $Id$ |
---|
| 4 | |
---|
| 5 | use strict; |
---|
| 6 | use warnings; |
---|
[319] | 7 | use base 'Epoll::DB::Poll::Bdata'; |
---|
[219] | 8 | |
---|
| 9 | =head1 NAME |
---|
| 10 | |
---|
[242] | 11 | Epoll::Model::Vote - Catalyst Model |
---|
[219] | 12 | |
---|
| 13 | =head1 DESCRIPTION |
---|
| 14 | |
---|
| 15 | Catalyst Model. |
---|
| 16 | |
---|
| 17 | =cut |
---|
| 18 | |
---|
[319] | 19 | sub set_voter { |
---|
| 20 | my ($self, $voter, $referal) = @_; |
---|
| 21 | $self->{voter} = $voter; |
---|
| 22 | $self->{referal} = $referal; |
---|
[219] | 23 | } |
---|
| 24 | |
---|
| 25 | sub add_item { |
---|
[319] | 26 | my ($self, $value, $weight) = @_; |
---|
| 27 | $value =~ s/^\s+//; |
---|
| 28 | $value =~ s/\s+$//; |
---|
| 29 | $value =~ s/\s+/ /g; |
---|
| 30 | $value = lc($value); |
---|
| 31 | $self->{data}{content}{$value} = $weight; |
---|
[219] | 32 | } |
---|
| 33 | |
---|
[319] | 34 | sub submit { |
---|
[219] | 35 | my ($self) = @_; |
---|
| 36 | |
---|
| 37 | for (0..2) { # 3 try |
---|
| 38 | # First we register voting has voted |
---|
[319] | 39 | $self->poll->_register_signing($self->{voter}, $self->{referal}) or return; # TODO error ? |
---|
[219] | 40 | |
---|
| 41 | # registring choices |
---|
[319] | 42 | if ($self->_store_crypted()) { |
---|
[219] | 43 | last; |
---|
| 44 | } else { |
---|
| 45 | $self->rollback; |
---|
| 46 | next; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | } |
---|
| 50 | # everything went fine, saving! |
---|
| 51 | $self->commit; |
---|
| 52 | |
---|
| 53 | $self->uid |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | =head1 AUTHOR |
---|
| 58 | |
---|
| 59 | Thauvin Olivier |
---|
| 60 | |
---|
| 61 | =head1 LICENSE |
---|
| 62 | |
---|
| 63 | This library is free software, you can redistribute it and/or modify |
---|
| 64 | it under the same terms as Perl itself or CeCILL. |
---|
| 65 | |
---|
| 66 | =cut |
---|
| 67 | |
---|
| 68 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.