Changeset 319 for trunk


Ignore:
Timestamp:
06/01/10 10:48:29 (14 years ago)
Author:
nanardon
Message:
  • support of several poll type
  • remove static result storage
Location:
trunk
Files:
3 added
17 edited
5 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r316 r319  
    2020lib/Epoll/DB/ImportV.pm 
    2121lib/Epoll/DB/Poll/Bdata.pm 
    22 lib/Epoll/DB/Poll/Results.pm 
    2322lib/Epoll/DB/Poll.pm 
    2423lib/Epoll/DB/Voting.pm 
  • trunk/lib/Epoll/Controller/Admin.pm

    r315 r319  
    129129            } else { 
    130130            } 
     131        } 
     132        if ($c->req->param('publish')) { 
     133            $c->model('Vote')->poll($c->stash->{voteid})->compute_results; 
     134            $c->model('Vote')->commit; 
    131135        }    
    132136    }; 
  • trunk/lib/Epoll/DB.pm

    r307 r319  
    77use base 'Epoll::DB::common'; 
    88use Epoll::DB::Poll; 
    9 use Epoll::DB::Poll::Results; 
    109 
    1110our $VERSION = '1.90'; 
     
    9493sub results { 
    9594    my ($self, $pollid) = @_; 
    96     Epoll::DB::Poll::Results->new($self->{dbstring}, $self->poll_id_from_uid($pollid)); 
     95    Epoll::DB::Poll->new($self->{dbstring}, $self->poll_id_from_uid($pollid)); 
    9796} 
    9897 
  • trunk/lib/Epoll/DB/Ballot.pm

    r242 r319  
    6767        q{ 
    6868        select ballot_item.*, value as v, 
    69         coalesce(ballot_map.to, corrected) as corrected 
     69        ballot_map.to as corrected 
    7070        from ballot_item join ballot on ballot.id = ballot_item.id 
    7171        left join ballot_map on ballot_map.poll = ballot.poll and 
  • trunk/lib/Epoll/DB/ImportV.pm

    r315 r319  
    66 
    77sub new { 
    8     my ($self, $type) = @_; 
     8    my ($class, $type) = @_; 
    99 
    1010    my $ctype = ucfirst(lc($type)); 
  • trunk/lib/Epoll/DB/Poll.pm

    r317 r319  
    1414use Epoll::DB::Choice; 
    1515use Epoll::DB::Poll::Bdata; 
     16use Epoll::DB::Poll::BSubmit; 
     17use YAML; 
    1618 
    1719=head1 NAME 
     
    112114    $voteid && $voteid =~ /^\d+$/ or return; 
    113115 
    114     bless { 
     116    my $poll = bless { 
    115117        voteid => $voteid, 
    116118        dbstring => $dbstring, 
    117119        db => Epoll::DB::common::_newdb($dbstring), 
    118120    }, $class; 
    119 } 
     121 
     122    my $type = $poll->type; 
     123 
     124    $type = ucfirst(lc($type)); 
     125    eval "require Epoll::DB::Poll::Type::$type;"; 
     126    if ($@) { 
     127        return; 
     128    } else { 
     129        return bless($poll, "Epoll::DB::Poll::Type::$type"); 
     130    } 
     131} 
     132 
     133sub type { lc($_[0]->info('type') || 'binary') } 
    120134 
    121135sub voteid { $_[0]->{voteid} } 
     
    467481sub decrypted_ballots { 
    468482    my ($self, $password) = @_; 
    469     my $privkey = $self->private_key($password) or return; 
    470     foreach ($self->list_ballot_need_dec) { 
     483    my $privkey; 
     484    if ($self->is_crypted) { 
     485        $privkey = $self->private_key($password) or return; 
     486    } 
     487    my $fetch_data = $self->db->prepare_cached( 
     488        q{select * from ballot_enc where decrypted = false and poll = ? 
     489            order by id} 
     490    ); 
     491    $fetch_data->execute($self->voteid); 
     492    while (my $res = $fetch_data->fetchrow_hashref) { 
    471493        my $bdata = $self->bdata; 
    472         $bdata->decrypt($_, $privkey); 
     494        $bdata->decrypt_data($res->{id}, $res->{data}, $res->{enckey}, $privkey) 
     495            and return; 
    473496    } 
    474497    1 
     
    477500sub register_ballot { 
    478501    my ($self, $vmail, $choice, $referal) = @_; 
    479  
    480     my $bdata = $self->bdata; 
    481     foreach (@{ $choice || []}) { 
    482         $bdata->add_item($_); 
    483     } 
    484     $bdata->submit($vmail, $referal) or do { 
    485         $self->rollback; 
    486         return; 
    487     }; 
    488  
    489     # everything went fine, saving! 
    490     $self->commit; 
    491  
    492     $bdata->uid 
     502    # TODO: warn, deprecated 
     503 
     504    my $bdata = $self->bsubmit; 
     505    if (!$choice) { 
     506    } elsif (ref $choice eq 'ARRAY') { 
     507        foreach (@{ $choice || []}) { 
     508            $bdata->add_item($_, 1); 
     509        } 
     510    } else { 
     511        foreach (keys %{ $choice || {}}) { 
     512            $bdata->add_item($_, $choice->{$_}); 
     513        } 
     514    } 
     515    $bdata->set_voter($vmail, $referal); 
     516    return $bdata->submit($vmail, $referal); 
    493517} 
    494518 
     
    514538sub auth_voting { 
    515539    my ($self, $mail, $password) = @_; 
    516     $self->voting_from_mail($mail)->auth($password); 
     540    if (my $voter = $self->voting_from_mail($mail)) { 
     541        return $voter->auth($password); 
     542    } else { 
     543        return; 
     544    } 
    517545} 
    518546 
     
    552580    my ($self) = @_; 
    553581    Epoll::DB::Poll::Bdata->new($self->{dbstring}, $self); 
     582} 
     583 
     584sub bsubmit { 
     585    my ($self) = @_; 
     586    Epoll::DB::Poll::BSubmit->new($self->{dbstring}, $self); 
    554587} 
    555588 
     
    742775    my $getval = $self->db->prepare_cached( 
    743776        q{ 
    744         select coalesce(corrected, value) as value from ballot join ballot_item 
     777        select value as value from ballot join ballot_item 
    745778        on ballot.id = ballot_item.id 
    746779        where poll = ? 
     
    749782            : '' 
    750783        ) . q{ 
    751         group by coalesce(corrected, value) order by coalesce(corrected, value) 
     784        group by value order by value 
    752785        } 
    753786    ); 
     
    790823            ); 
    791824 
    792             $sth->execute($self->voteid, $from, $to) or $self->rollback; 
     825            $sth->execute($self->voteid, $from, $to) or do { 
     826                $self->rollback; 
     827                return; 
     828            }; 
    793829        } 
    794830    } 
    795831    $self->commit; 
     832    return 1; 
    796833} 
    797834 
     
    817854        }); 
    818855 
    819         $add->execute($self->voteid, $id || '', $mail, $extern_auth, $extern_uid); 
     856        return $add->execute($self->voteid, $id || '', $mail, $extern_auth, $extern_uid); 
     857    } else { 
     858        return 1; 
    820859    } 
    821860} 
     
    946985} 
    947986 
     987 
     988 
    948989######### 
    949990# Count # 
     
    951992 
    952993sub ballot_count { 
    953     my ($self) = @_; 
    954     return $self->is_crypted 
    955         ? $self->ballot_count_crypt 
    956         : $self->ballot_count_clear; 
     994    ballots_count(@_); 
     995} 
     996 
     997sub ballots_count { 
     998    my ($self) = @_; 
     999    return $self->ballot_count_crypt; 
    9571000} 
    9581001 
     
    9671010    my $res = $sth->fetchrow_hashref; 
    9681011    $sth->finish; 
    969     $res->{count} 
     1012    $res->{count} || 0 
    9701013} 
    9711014 
     
    9801023    my $res = $sth->fetchrow_hashref; 
    9811024    $sth->finish; 
    982     $res->{count} 
    983 } 
    984  
    985 sub voting_count { 
     1025    $res->{count} || 0 
     1026} 
     1027 
     1028sub voting_count { voters_count(@_) } 
     1029 
     1030sub voters_count { 
    9861031    my ($self) = @_; 
    9871032 
     
    10161061sub not_signing_count { 
    10171062    my ($self) = @_; 
    1018     my $sth = $self->db->prepare_cached( 
    1019         q{ 
    1020         select count(*) from voting where key 
    1021         not in (select key from signing) 
     1063    $self->voters_count - $self->signing_count; 
     1064} 
     1065 
     1066sub valid_ballot_count { 
     1067    my ($self) = @_; 
     1068 
     1069    my $sth = $self->db->prepare_cached( 
     1070        q{ 
     1071        select count(*) from ballot where poll = ? 
     1072            and (invalid = 'f' or invalid is NULL) 
    10221073        } 
    10231074    ); 
     
    10271078    $sth->finish; 
    10281079    $res->{count} 
     1080} 
     1081 
     1082sub invalid_ballot_count { 
     1083    my ($self) = @_; 
     1084 
     1085    my $sth = $self->db->prepare_cached( 
     1086        q{ 
     1087        select count(*) from ballot where poll = ? 
     1088        and invalid = 't' 
     1089        } 
     1090    ); 
     1091 
     1092    $sth->execute($self->voteid); 
     1093    my $res = $sth->fetchrow_hashref; 
     1094    $sth->finish; 
     1095    $res->{count} || 0 
     1096} 
     1097 
     1098sub empty_ballot_count { 
     1099    my ($self) = @_; 
     1100 
     1101    my $sth = $self->db->prepare_cached( 
     1102        q{ 
     1103        select count(*) from ballot where poll = ? 
     1104        and id not in (select id from ballot_item) 
     1105        and (invalid = 'false' or invalid is null) 
     1106        } 
     1107    ); 
     1108 
     1109    $sth->execute($self->voteid); 
     1110    my $res = $sth->fetchrow_hashref; 
     1111    $sth->finish; 
     1112    $res->{count} 
     1113} 
     1114 
     1115sub not_empty_ballot_count { 
     1116    my ($self) = @_; 
     1117 
     1118    my $sth = $self->db->prepare_cached( 
     1119        q{ 
     1120        select count(*) from ballot where poll = ? 
     1121        and id in (select id from ballot_item) 
     1122        and (invalid = 'false' or invalid is null) 
     1123        } 
     1124    ); 
     1125 
     1126    $sth->execute($self->voteid); 
     1127    my $res = $sth->fetchrow_hashref; 
     1128    $sth->finish; 
     1129    $res->{count} || 0 
     1130} 
     1131 
     1132sub compute_results { 
     1133    my ($self) = @_; 
     1134    $self->param('static_results', 
     1135        YAML::Dump($self->_compute_results)); 
     1136} 
     1137 
     1138sub results { 
     1139    my ($self) = @_; 
     1140    if (my $res = YAML::Load($self->info('static_results'))) { 
     1141        return $res 
     1142    } else { 
     1143        return; 
     1144    } 
    10291145} 
    10301146 
     
    10321148# CLEANING DATA # 
    10331149################# 
     1150 
     1151sub delete_ballots { 
     1152    my ($self) = @_; 
     1153 
     1154    $self->store_results; 
     1155    $self->_delete_ballot; 
     1156    $self->commit; 
     1157} 
    10341158 
    10351159sub _delete_ballot { 
  • trunk/lib/Epoll/DB/Poll/BSubmit.pm

    r315 r319  
    1 package Epoll::DB::Poll::Bdata; 
     1package Epoll::DB::Poll::BSubmit; 
    22 
    33# $Id$ 
     
    55use strict; 
    66use warnings; 
    7 use base 'Epoll::DB::common'; 
    8 use Epoll::DB::Poll; 
    9 use XML::Simple; 
    10 use Crypt::CBC; 
    11 use Crypt::DES_EDE3; # Called from CBC 
     7use base 'Epoll::DB::Poll::Bdata'; 
    128 
    139=head1 NAME 
     
    2117=cut 
    2218 
    23 sub new { 
    24     my ($class, $dbstring, $poll) = @_; 
    25      
    26     bless { 
    27         poll => $poll, 
    28         dbstring => $dbstring, 
    29         db => Epoll::DB::common::_newdb($dbstring), 
    30         data => {} 
    31     }, $class; 
    32 } 
    33  
    34 sub voteid { $_[0]->poll->voteid } 
    35  
    36 sub poll { 
    37     my ($self) = @_; 
    38     $self->{poll}; 
    39 } 
    40  
    41 sub uid { 
    42     my ($self) = @_; 
    43     $self->{data}{id} ||= Epoll::DB::common::gen_uid(); 
    44 } 
    45  
    46 sub items { 
    47     my ($self) = @_; 
    48     @{$self->{data}{content} || []} 
     19sub set_voter { 
     20    my ($self, $voter, $referal) = @_; 
     21    $self->{voter} = $voter; 
     22    $self->{referal} = $referal; 
    4923} 
    5024 
    5125sub add_item { 
    52     my ($self, @items) = @_; 
    53     foreach (@items) { 
    54         s/^\s+//; 
    55         s/\s+$//; 
    56         s/\s+/ /g; 
    57         $_ = lc($_); 
    58  
    59         push(@{$self->{data}{content}}, $_); 
    60     } 
    61 } 
    62  
    63 sub xmlout { 
    64     my ($self) = @_; 
    65     my $xml = XML::Simple->new(ForceArray => 1, RootName => 'ballot'); 
    66     $xml->XMLout({ 
    67         id => $self->uid, 
    68         content => [ $self->items ], 
    69     }); 
    70 } 
    71  
    72 sub xmlin { 
    73     my ($self, $data) = @_; 
    74     my $xmldata = XMLin($data, ForceArray => ['content']); 
    75     $self->{data}{id} = $xmldata->{id}; 
    76     if ($xmldata->{content}) { 
    77         if (ref $xmldata->{content}) { 
    78             foreach (@{ $xmldata->{content} || []}) { 
    79                 $self->add_item($_); 
    80             } 
    81         } else { 
    82             $self->add_item($xmldata->{content}); 
    83         } 
    84     } 
     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; 
    8532} 
    8633 
    8734sub submit { 
    88     my ($self, $voting, $referal) = @_; 
     35    my ($self) = @_; 
    8936     
    9037    for (0..2) { # 3 try 
    9138        # First we register voting has voted 
    92         $self->poll->_register_signing($voting, $referal) or return; # TODO error ? 
     39        $self->poll->_register_signing($self->{voter}, $self->{referal}) or return; # TODO error ? 
    9340 
    9441        # registring choices 
    95         if ($self->poll->is_crypted 
    96             ? $self->_store_crypted() 
    97             : $self->_store_clear()) { 
     42        if ($self->_store_crypted()) { 
    9843            last; 
    9944        } else { 
     
    10752 
    10853    $self->uid 
    109 } 
    110  
    111 sub _store_clear { 
    112     my ($self) = @_; 
    113     my $addb = $self->db->prepare_cached( 
    114         q{ 
    115         insert into ballot (id, poll, invalid) values (?,?,?) 
    116         } 
    117     ); 
    118  
    119     my $needvalid = 'f'; 
    120     my %items = (); 
    121     foreach($self->items) { 
    122         if ($self->poll->find_choice_key($_)) { 
    123             $items{$_} = 't'; 
    124         } else { 
    125             $items{$_} = 'f'; 
    126             $needvalid = undef; 
    127         } 
    128     } 
    129  
    130     $addb->execute($self->uid, $self->voteid, $needvalid) or do { 
    131         $self->rollback; 
    132         return; 
    133     }; 
    134  
    135     my $addbc = $self->db->prepare_cached( 
    136         q{ 
    137         insert into ballot_item (id, value, fromlist) values (?,?,?) 
    138         } 
    139     ); 
    140     foreach (keys %items) { 
    141         $_ or next; 
    142         $addbc->execute($self->uid, $_, $items{$_}) or do { 
    143             $self->rollback; 
    144             return; 
    145         }; 
    146     } 
    147  
    148     1; 
    149 } 
    150  
    151 sub _store_crypted { 
    152     my ($self) = @_; 
    153     my $symkey = map{ chr(rand(256)) } (1 .. 24); 
    154     my $cipher = new Crypt::CBC($symkey, 'DES_EDE3'); 
    155     my $encryptedballot = $cipher->encrypt_hex( 
    156         $self->xmlout() 
    157     ); 
    158     my $encsymkey = $self->poll->rsa->encrypt ( 
    159         Message    => $symkey, 
    160         Key        => $self->poll->public_key, 
    161         Armour     => 1, 
    162     ) || die $self->poll->rsa->errstr(); 
    163  
    164     my $addenc = $self->db->prepare_cached( 
    165         q{insert into ballot_enc (id, data, enckey, poll) values (?,?,?,?)} 
    166     ); 
    167  
    168     my $uid = Epoll::DB::common::gen_uid(); 
    169     $addenc->execute($uid, $encryptedballot, $encsymkey, $self->voteid); 
    170 } 
    171  
    172 sub _load_crypted { 
    173     my ($self, $ballotid, $privkey) = @_; 
    174     my $sth = $self->db->prepare_cached( 
    175         q{select * from ballot_enc where id = ? for update} 
    176     ); 
    177     $sth->execute($ballotid); 
    178     my $ballot = $sth->fetchrow_hashref; 
    179     $sth->finish; 
    180     my $encsymkey = $ballot->{enckey}; 
    181     my $data = $ballot->{data}; 
    182     my $symkey = $self->poll->rsa->decrypt ( 
    183         Cyphertext => $encsymkey, 
    184         Key        => $privkey, 
    185         Armour     => 1, 
    186     ) || die $self->poll->rsa->errstr(); 
    187     my $cipher = new Crypt::CBC($symkey, 'DES_EDE3'); 
    188     $self->xmlin($cipher->decrypt_hex($data)); 
    189 } 
    190  
    191 sub decrypt { 
    192     my ($self, $ballotid, $privkey) = @_; 
    193     $self->_load_crypted($ballotid, $privkey); 
    194     $self->_store_clear or return; 
    195     my $upd = $self->db->prepare_cached(q{update ballot_enc set decrypted = true where id = ?}); 
    196     if ($upd->execute($ballotid)) { 
    197         $self->commit; 
    198         return; 
    199     } else { 
    200         $self->rollback; 
    201         return 1; 
    202     } 
    20354} 
    20455 
  • trunk/lib/Epoll/DB/Poll/Bdata.pm

    r242 r319  
    77use base 'Epoll::DB::common'; 
    88use Epoll::DB::Poll; 
    9 use XML::Simple; 
     9use YAML (); 
    1010use Crypt::CBC; 
    1111use Crypt::DES_EDE3; # Called from CBC 
     
    2828        dbstring => $dbstring, 
    2929        db => Epoll::DB::common::_newdb($dbstring), 
    30         data => {} 
     30        data => {}, 
    3131    }, $class; 
    3232} 
     
    4444} 
    4545 
    46 sub items { 
    47     my ($self) = @_; 
    48     @{$self->{data}{content} || []} 
    49 } 
    50  
    51 sub add_item { 
    52     my ($self, @items) = @_; 
    53     foreach (@items) { 
    54         s/^\s+//; 
    55         s/\s+$//; 
    56         s/\s+/ /g; 
    57         $_ = lc($_); 
    58  
    59         push(@{$self->{data}{content}}, $_); 
    60     } 
    61 } 
    62  
    6346sub xmlout { 
    6447    my ($self) = @_; 
    65     my $xml = XML::Simple->new(ForceArray => 1, RootName => 'ballot'); 
    66     $xml->XMLout({ 
    67         id => $self->uid, 
    68         content => [ $self->items ], 
    69     }); 
     48    $self->uid; 
     49    YAML::Dump($self->{data}); 
    7050} 
    7151 
    7252sub xmlin { 
    7353    my ($self, $data) = @_; 
    74     my $xmldata = XMLin($data, ForceArray => ['content']); 
    75     $self->{data}{id} = $xmldata->{id}; 
    76     if ($xmldata->{content}) { 
    77         if (ref $xmldata->{content}) { 
    78             foreach (@{ $xmldata->{content} || []}) { 
    79                 $self->add_item($_); 
    80             } 
    81         } else { 
    82             $self->add_item($xmldata->{content}); 
    83         } 
    84     } 
    85 } 
    86  
    87 sub submit { 
    88     my ($self, $voting, $referal) = @_; 
    89      
    90     for (0..2) { # 3 try 
    91         # First we register voting has voted 
    92         $self->poll->_register_signing($voting, $referal) or return; # TODO error ? 
    93  
    94         # registring choices 
    95         if ($self->poll->is_crypted 
    96             ? $self->_store_crypted() 
    97             : $self->_store_clear()) { 
    98             last; 
    99         } else { 
    100             $self->rollback; 
    101             next; 
    102         } 
    103  
    104     } 
    105         # everything went fine, saving! 
    106     $self->commit; 
    107  
    108     $self->uid 
     54    $self->{data} = YAML::Load($data); 
    10955} 
    11056 
     
    11965    my $needvalid = 'f'; 
    12066    my %items = (); 
    121     foreach($self->items) { 
     67    foreach(keys %{$self->{data}{content} || {}}) { 
    12268        if ($self->poll->find_choice_key($_)) { 
    12369            $items{$_} = 't'; 
     
    13581    my $addbc = $self->db->prepare_cached( 
    13682        q{ 
    137         insert into ballot_item (id, value, fromlist) values (?,?,?) 
     83        insert into ballot_item (id, value, fromlist, weight) values (?,?,?,?) 
    13884        } 
    13985    ); 
    140     foreach (keys %items) { 
     86    foreach (keys %{$self->{data}{content} || {}}) { 
    14187        $_ or next; 
    142         $addbc->execute($self->uid, $_, $items{$_}) or do { 
     88        $addbc->execute($self->uid, $_, $items{$_}, $self->{data}{content}{$_}) or do { 
    14389            $self->rollback; 
    14490            return; 
     
    15197sub _store_crypted { 
    15298    my ($self) = @_; 
    153     my $symkey = map{ chr(rand(256)) } (1 .. 24); 
    154     my $cipher = new Crypt::CBC($symkey, 'DES_EDE3'); 
    155     my $encryptedballot = $cipher->encrypt_hex( 
    156         $self->xmlout() 
    157     ); 
    158     my $encsymkey = $self->poll->rsa->encrypt ( 
    159         Message    => $symkey, 
    160         Key        => $self->poll->public_key, 
    161         Armour     => 1, 
    162     ) || die $self->poll->rsa->errstr(); 
    163  
     99     
    164100    my $addenc = $self->db->prepare_cached( 
    165101        q{insert into ballot_enc (id, data, enckey, poll) values (?,?,?,?)} 
    166102    ); 
    167  
    168103    my $uid = Epoll::DB::common::gen_uid(); 
    169     $addenc->execute($uid, $encryptedballot, $encsymkey, $self->voteid); 
     104     
     105    if (my $pollkey = $self->poll->public_key) { 
     106        my $symkey = map{ chr(rand(256)) } (1 .. 24); 
     107        my $cipher = new Crypt::CBC($symkey, 'DES_EDE3'); 
     108        my $encryptedballot = $cipher->encrypt_hex( 
     109            $self->xmlout() 
     110        ); 
     111        my $encsymkey = $self->poll->rsa->encrypt ( 
     112            Message    => $symkey, 
     113            Key        => $self->poll->public_key, 
     114            Armour     => 1, 
     115        ) || die $self->poll->rsa->errstr(); 
     116        $addenc->execute($uid, $encryptedballot, $encsymkey, $self->voteid); 
     117    } else { 
     118        $addenc->execute($uid, $self->xmlout(), undef, $self->voteid); 
     119    } 
    170120} 
    171121 
     
    178128    my $ballot = $sth->fetchrow_hashref; 
    179129    $sth->finish; 
    180     my $encsymkey = $ballot->{enckey}; 
    181     my $data = $ballot->{data}; 
    182     my $symkey = $self->poll->rsa->decrypt ( 
    183         Cyphertext => $encsymkey, 
    184         Key        => $privkey, 
    185         Armour     => 1, 
    186     ) || die $self->poll->rsa->errstr(); 
    187     my $cipher = new Crypt::CBC($symkey, 'DES_EDE3'); 
    188     $self->xmlin($cipher->decrypt_hex($data)); 
     130    $self->_load_crypted_data($ballot->{data}, $ballot->{enckey}, $privkey); 
     131} 
     132 
     133sub _load_crypted_data { 
     134    my ($self, $data, $encsymkey, $privkey) = @_; 
     135    if ($encsymkey) { 
     136        my $symkey = $self->poll->rsa->decrypt ( 
     137            Cyphertext => $encsymkey, 
     138            Key        => $privkey, 
     139            Armour     => 1, 
     140        ) || die $self->poll->rsa->errstr(); 
     141        my $cipher = new Crypt::CBC($symkey, 'DES_EDE3'); 
     142        return $self->xmlin($cipher->decrypt_hex($data)); 
     143    } else { 
     144        return $self->xmlin($data); 
     145    } 
     146} 
     147 
     148sub decrypt_data { 
     149    my ($self, $ballotid, $data, $encsymkey, $privkey) = @_; 
     150    if ($self->_load_crypted_data($data, $encsymkey, $privkey) && 
     151        $self->_store_clear && 
     152        $self->_set_decrypted($ballotid)) { 
     153        $self->commit; 
     154        return; 
     155    } else { 
     156        $self->rollback; 
     157        return 1; 
     158    } 
     159} 
     160 
     161sub _set_decrypted { 
     162    my ($self, $ballotid) = @_; 
     163    my $upd = $self->db->prepare_cached(q{update ballot_enc set decrypted = true where id = ?}); 
     164    $upd->execute($ballotid) 
    189165} 
    190166 
     
    193169    $self->_load_crypted($ballotid, $privkey); 
    194170    $self->_store_clear or return; 
    195     my $upd = $self->db->prepare_cached(q{update ballot_enc set decrypted = true where id = ?}); 
    196     if ($upd->execute($ballotid)) { 
     171    if ($self->_set_decrypted($ballotid)) { 
    197172        $self->commit; 
    198173        return; 
  • trunk/lib/Epoll/DB/Poll/Type/Binary.pm

    r315 r319  
    1 package Epoll::DB::Poll::Results; 
     1package Epoll::DB::Poll::Type::Binary; 
    22 
    33# $Id$ 
     
    66use warnings; 
    77use base 'Epoll::DB::Poll'; 
    8 use XML::Simple; 
    9 use vars qw($AUTOLOAD); 
     8use YAML; 
    109 
    1110=head1 NAME 
     
    1918=cut 
    2019 
    21 sub new { 
    22     my ($class, @args) = @_; 
     20sub _check_ballot { 
     21    my ($self, $bdata) = @_; 
    2322 
    24     my $res = $class->SUPER::new(@args); 
    25  
    26     $res = bless $res, $class; 
    27     $res->load_static_data; 
    28     $res 
    2923} 
    3024 
    31 sub AUTOLOAD { 
    32     my ($self, @args) = @_; 
    33     my ($constname, $sub) = $AUTOLOAD =~ m/(.*)::([^:]+)/; 
    34     $sub =~ /^__(.*)/ and die "No sub $1"; 
    35     if ($self->{static_results}) { 
    36         return $self->{static_results}{$sub}; 
    37     } else { 
    38         my $realsub = "__$sub"; 
    39         return $self->$realsub(@args); 
    40     } 
     25sub _compute_results { 
     26    my ($self) = @_; 
     27    $self->_results( 
     28        $self->info('empty_ballot_has_voice') 
     29        ? 0 
     30        : 1 
     31    ); 
    4132} 
    4233 
    43 sub DESTROY {} 
    44  
    45 sub load_static_data { 
     34sub absolute_majority { 
    4635    my ($self) = @_; 
    47     if (my $res = $self->info('static_results')) { 
    48         $self->{static_results} = XMLin( 
    49             $res, 
    50             ForceArray => ['results'] 
    51         ); 
    52     } 
    53 } 
    54  
    55 sub ballot_count { 
    56     my ($self) = @_; 
    57     if ($self->{static_results}) { 
    58         return $self->{static_results}{ballot_count}; 
    59     } else { 
    60         return $self->SUPER::ballot_count(); 
    61     } 
    62 } 
    63  
    64 sub __absolute_majority { 
    65     my ($self) = @_; 
    66     my $ballot_count = $self->voices_ballot_count; 
    67     return int($ballot_count / 2) + 1; 
     36    return int($self->_voices_ballot_count / 2) + 1; 
    6837}     
    6938 
    70 sub __abstention { 
     39sub ___abstention { 
    7140    my ($self) = @_; 
    7241     
     
    8554} 
    8655 
    87 sub __ballot_count_nonull {not_empty_ballot_count(@_)} 
     56sub voices_ballot_count { _voices_ballot_count(@_) } 
    8857 
    89 sub __voices_ballot_count { 
     58sub _voices_ballot_count { 
    9059    my ($self) = @_; 
    9160    return $self->info('empty_ballot_has_voice') 
    92             ? $self->valid_ballot_count 
    93             : $self->not_empty_ballot_count; 
    94 } 
    95  
    96 sub __valid_ballot_count { 
    97     my ($self) = @_; 
    98  
    99     my $sth = $self->db->prepare_cached( 
    100         q{ 
    101         select count(*) from ballot where poll = ? 
    102         and (invalid = 'f' or invalid is NULL) 
    103         } 
    104     ); 
    105  
    106     $sth->execute($self->voteid); 
    107     my $res = $sth->fetchrow_hashref; 
    108     $sth->finish; 
    109     $res->{count} 
    110 } 
    111  
    112 sub __invalid_ballot_count { 
    113     my ($self) = @_; 
    114  
    115     my $sth = $self->db->prepare_cached( 
    116         q{ 
    117         select count(*) from ballot where poll = ? 
    118         and invalid = 't' 
    119         } 
    120     ); 
    121  
    122     $sth->execute($self->voteid); 
    123     my $res = $sth->fetchrow_hashref; 
    124     $sth->finish; 
    125     $res->{count} 
    126 } 
    127  
    128 sub __empty_ballot_count { 
    129     my ($self) = @_; 
    130  
    131     my $sth = $self->db->prepare_cached( 
    132         q{ 
    133         select count(*) from ballot where poll = ? 
    134         and id not in (select id from ballot_item) 
    135         and (invalid = 'false' or invalid is null) 
    136         } 
    137     ); 
    138  
    139     $sth->execute($self->voteid); 
    140     my $res = $sth->fetchrow_hashref; 
    141     $sth->finish; 
    142     $res->{count} 
    143 } 
    144  
    145 sub __not_empty_ballot_count { 
    146     my ($self) = @_; 
    147  
    148     my $sth = $self->db->prepare_cached( 
    149         q{ 
    150         select count(*) from ballot where poll = ? 
    151         and id in (select id from ballot_item) 
    152         and (invalid = 'false' or invalid is null) 
    153         } 
    154     ); 
    155  
    156     $sth->execute($self->voteid); 
    157     my $res = $sth->fetchrow_hashref; 
    158     $sth->finish; 
    159     $res->{count} 
    160 } 
    161  
    162 sub results_count { 
    163     my ($self) = @_; 
    164     $self->_results(); 
    165 } 
    166  
    167 sub results_nonull { 
    168     my ($self) = @_; 
    169     $self->_results(1); 
    170 } 
    171  
    172 sub __results { 
    173     my ($self) = @_; 
    174     $self->_results( 
    175         $self->info('empty_ballot_has_voice') 
    176         ? 0 
    177         : 1 
    178     ); 
     61        ? $self->valid_ballot_count 
     62        : $self->not_empty_ballot_count; 
    17963} 
    18064 
     
    18670        select count(ballot.id), value from 
    18771        ( 
    188         select NULL as id, label as value from choice where poll = ? 
     72        select NULL as id, label as value from choice where poll = $1 
    18973        union 
    190         select ballot.id, coalesce(corrected, ballot_map.to, value) as "value" from ballot 
     74        select ballot.id, coalesce(ballot_map.to, value) as "value" from ballot 
    19175        } . ($nonull ? '' : ' left ') . q{ join ballot_item 
    19276        on ballot.id = ballot_item.id  
    193         left join ballot_map on ballot.poll = ballot_map.poll and ballot_map.from = ballot_item.value 
    194         where ballot.poll = ? and (invalid = 'false' or invalid is null 
     77        left join ballot_map on ballot_map.from = ballot_item.value and 
     78        ballot_map.poll = ballot.poll 
     79        where ballot.poll = $1 and (invalid = 'false' or invalid is null 
    19580        ) 
    196         group by ballot.id, coalesce(corrected, ballot_map.to, value)) as ballot 
     81        group by ballot.id, coalesce(ballot_map.to, value)) as ballot 
    19782        group by value 
    19883        order by count desc, value 
    19984        } 
    20085    ); 
    201     $sth->execute($self->voteid, $self->voteid); 
     86    $sth->execute($self->voteid); 
    20287    my @results; 
    20388    my $abs_maj = $self->absolute_majority; 
    20489    my $wanted_count = $self->info('elected_count'); 
    205     my $voice_count = $self->voices_ballot_count; 
     90    my $voice_count = $self->_voices_ballot_count; 
    20691    while (my $res = $sth->fetchrow_hashref) { 
    20792        if ($res->{count} >= $abs_maj) { 
     
    227112} 
    228113 
    229 sub dump_results { 
    230     my ($self) = @_; 
    231     my $xml = XML::Simple->new(ForceArray => 1, RootName => 'results'); 
    232     my %results; 
    233  
    234     foreach my $val (qw( 
    235         ballot_count 
    236         ), 
    237         map { s/^__//; $_ } grep { /^__/ } keys %{Epoll::DB::Poll::Results::} 
    238         ) { 
    239         $results{$val} = $self->$val(); 
    240     } 
    241     $xml->XMLout({ 
    242         %results 
    243     }); 
    244 } 
    245  
    246 sub delete_ballots { 
    247     my ($self) = @_; 
    248  
    249     $self->param('static_results' => $self->dump_results); 
    250     $self->_delete_ballot; 
    251     $self->commit; 
    252     $self->{static_results} = XMLin( 
    253         $self->info('static_results'), 
    254         ForceArray => ['results'] 
    255     ); 
    256 } 
    257114 
    258115=head1 AUTHOR 
  • trunk/lib/Epoll/I18N/fr.po

    r315 r319  
    8181msgstr "Bulletins" 
    8282 
     83#: root/templates/includes/poll_results.tt:47 
     84#, fuzzy 
     85msgid "Ballot list:" 
     86msgstr "Bulletins:" 
     87 
    8388#: root/templates/includes/poll.tt:22 root/templates/includes/poll.tt:32 
    8489msgid "Ballot:" 
    8590msgstr "Bulletins:" 
    8691 
     92#: root/templates/includes/poll_results.tt:26 
     93#, fuzzy 
     94msgid "Ballots count" 
     95msgstr "bulletins contenant:" 
     96 
     97#: root/templates/admin/votersimport.tt:13 
     98#: root/templates/admin/votersimport.tt:14 
     99msgid "CSV file" 
     100msgstr "" 
     101 
    87102#: root/templates/admin/denied.tt:4 
    88103msgid "Cannot modify a started or finish poll" 
     
    161176msgstr "Télécharger la clef privée" 
    162177 
     178#: root/templates/admin/votersimport.tt:10 
     179#: root/templates/admin/votersimport.tt:11 
     180msgid "Dummy" 
     181msgstr "" 
     182 
    163183#: root/templates/includes/ballot_form.tt:59 
    164184msgid "Empty ballot" 
     
    169189msgstr "Saisissez le mot de passe d'administration du vote" 
    170190 
     191#: root/templates/admin/votersimport.tt:48 
     192msgid "Enter here a comment to explain the password to use" 
     193msgstr "" 
     194 
    171195#: root/templates/admin/includes/ballot_decrypt.tt:8 
    172196msgid "Enter poll key here:" 
     
    208232msgid "From voting list" 
    209233msgstr "Depuis la liste des votants" 
     234 
     235#: root/templates/includes/poll_results.tt:49 
     236msgid "Id" 
     237msgstr "" 
     238 
     239#: root/templates/admin/votersimport.tt:51 
     240msgid "Import this list" 
     241msgstr "" 
    210242 
    211243#: root/templates/ballot/login.tt:6 
     
    246278msgstr "Juin" 
    247279 
     280#: root/templates/admin/votersimport.tt:16 
     281#: root/templates/admin/votersimport.tt:17 
     282msgid "LDAP" 
     283msgstr "" 
     284 
    248285#: root/templates/admin/includes/poll_extra_settings.tt:9 
    249286msgid "Mail include ballot id" 
     
    311348msgstr "Nombre" 
    312349 
     350#: root/templates/includes/poll_results.tt:17 
     351#, fuzzy 
     352msgid "Number of choice to retain:" 
     353msgstr "Nombre de personnes à élire" 
     354 
     355#: root/templates/includes/poll_results.tt:30 
     356#, fuzzy 
     357msgid "Number of empty ballot" 
     358msgstr "Nombre de personnes à élire" 
     359 
    313360#: root/templates/admin/ballot.tt:22 
    314361msgid "Number of free input fields:" 
    315362msgstr "Nombre de champ de saisie libre:" 
     363 
     364#: root/templates/includes/poll_results.tt:35 
     365#, fuzzy 
     366msgid "Number of nul ballot" 
     367msgstr "Nombre de personnes à élire" 
    316368 
    317369#: root/templates/admin/ballot.tt:15 
     
    344396msgstr "A participé" 
    345397 
     398#: root/templates/includes/poll_results.tt:21 
     399#, fuzzy 
     400msgid "Participation" 
     401msgstr "A participé" 
     402 
    346403#: root/templates/newpoll/index.tt:27 
    347404msgid "Password" 
     
    366423msgstr "Merci de confirmer l'effacement du vote %1" 
    367424 
     425#: root/templates/includes/poll_results.tt:13 
     426msgid "Poll administrator must validate some ballot" 
     427msgstr "" 
     428 
    368429#: root/templates/admin/date.tt:124 
    369430msgid "Poll end:" 
     
    391452msgstr "Prévisualisation du bulletin" 
    392453 
     454#: root/templates/includes/poll_results.tt:90 
     455msgid "Results are not yet published" 
     456msgstr "" 
     457 
    393458#: root/templates/ballot/done.tt:16 root/templates/ballot/signed.tt:6 
    394459msgid "Results will be available" 
    395460msgstr "Les résultats seront disponibles" 
    396461 
     462#: root/templates/includes/poll_results.tt:15 
     463#, fuzzy 
     464msgid "Results:" 
     465msgstr "RÚglement:" 
     466 
    397467#: root/templates/admin/includes/poll_settings.tt:13 
    398468msgid "Rules:" 
     
    428498msgid "Sunday" 
    429499msgstr "Dimanche" 
     500 
     501#: root/templates/includes/poll_results.tt:12 
     502msgid "Temporary results" 
     503msgstr "" 
    430504 
    431505#: root/templates/newpoll/request.tt:7 
     
    481555msgstr "Mardi" 
    482556 
     557#: root/templates/admin/votersimport.tt:47 
     558msgid "Use external authentication" 
     559msgstr "" 
     560 
    483561#: root/templates/ballot/default.tt:43 
    484562msgid "Valid" 
     
    585663msgstr "bulletins contenant:" 
    586664 
     665#: root/templates/includes/poll_results.tt:54 
     666msgid "comment" 
     667msgstr "" 
     668 
    587669#: root/templates/admin/includes/poll_settings.tt:49 
    588670msgid "crypt the poll" 
    589671msgstr "Chiffrer ce vote" 
     672 
     673#: root/templates/includes/poll_results.tt:50 
     674msgid "date (=> view as)" 
     675msgstr "" 
    590676 
    591677#: root/templates/admin/date.tt:116 root/templates/admin/date.tt:125 
     
    607693msgstr "pour %1 à élire" 
    608694 
     695#: root/templates/importv/csv.tt:1 
     696msgid "format:" 
     697msgstr "format:" 
     698 
    609699#: root/templates/includes/signing_list.tt:23 
    610700msgid "has vote" 
     
    620710msgstr "si différent du nombre de choix" 
    621711 
    622 #: root/templates/admin/validate.tt:77 
     712#: root/templates/admin/validate.tt:82 
    623713msgid "input value" 
    624714msgstr "valeur saisie" 
     
    628718msgstr "invalide" 
    629719 
     720#: root/templates/includes/poll_results.tt:76 
     721#, fuzzy 
     722msgid "invalided" 
     723msgstr "invalide" 
     724 
    630725#: root/templates/admin/validate.tt:56 
    631726msgid "is not valid" 
     
    640735msgstr "lister les bulletins:" 
    641736 
    642 #: root/templates/admin/validate.tt:75 
     737#: root/templates/admin/validate.tt:80 
    643738msgid "map ballot value" 
    644739msgstr "mapper les valeurs des bulletins" 
     
    648743msgstr "modifier mon vote" 
    649744 
    650 #: root/templates/admin/validate.tt:77 
     745#: root/templates/admin/validate.tt:82 
    651746msgid "must be see as" 
    652747msgstr "doit être vu comme" 
     748 
     749#: root/templates/includes/poll_results.tt:78 
     750#, fuzzy 
     751msgid "must be validated" 
     752msgstr "Des bulletins doivent être validés" 
    653753 
    654754#: root/templates/admin/validate.tt:12 
     
    656756msgstr "necessitant une validation" 
    657757 
     758#: root/templates/includes/poll_results.tt:52 
     759msgid "not from list" 
     760msgstr "" 
     761 
     762#: root/templates/includes/poll_results.tt:49 
     763#, fuzzy 
     764msgid "number" 
     765msgstr "Nombre" 
     766 
    658767#: root/templates/admin/voters.tt:59 
    659768msgid "password sent" 
    660769msgstr "mot de passe envoyé" 
    661770 
     771#: root/templates/admin/validate.tt:74 
     772msgid "publish results" 
     773msgstr "" 
     774 
    662775#: root/mail/poll_reminder_voting.tt:26 
    663776msgid "running" 
     
    668781msgstr "enregistrer" 
    669782 
     783#: root/templates/admin/votersimport.tt:33 
     784msgid "search..." 
     785msgstr "" 
     786 
     787#: root/templates/admin/votersimport.tt:20 
     788#, fuzzy 
     789msgid "select" 
     790msgstr "Effacer" 
     791 
    670792#: root/templates/admin/voters.tt:30 
    671793msgid "send password" 
     
    704826msgstr "L'identifiant de vote bulletin est:" 
    705827 
     828#, fuzzy 
     829#~ msgid "Ballot Number" 
     830#~ msgstr "Bulletins" 
     831 
     832#, fuzzy 
     833#~ msgid "Elected" 
     834#~ msgstr "Effacer" 
     835 
     836#, fuzzy 
     837#~ msgid "Number of voice" 
     838#~ msgstr "Nombre de choix possibles:" 
     839 
     840#, fuzzy 
     841#~ msgid "Number of voices" 
     842#~ msgstr "Nombre de choix possibles:" 
     843 
     844#, fuzzy 
     845#~ msgid "choice" 
     846#~ msgstr "Choix libre" 
     847 
    706848#~ msgid "From a csv file" 
    707849#~ msgstr "Depuis un fichier CSV" 
    708850 
    709 #~ msgid "format:" 
    710 #~ msgstr "format:" 
    711  
    712851#~ msgid "Voting" 
    713852#~ msgstr "Votant" 
  • trunk/lib/Epoll/I18N/messages.pot

    r315 r319  
    7979msgstr "" 
    8080 
     81#: root/templates/includes/poll_results.tt:47 
     82msgid "Ballot list:" 
     83msgstr "" 
     84 
    8185#: root/templates/includes/poll.tt:22 root/templates/includes/poll.tt:32 
    8286msgid "Ballot:" 
    8387msgstr "" 
    8488 
     89#: root/templates/includes/poll_results.tt:26 
     90msgid "Ballots count" 
     91msgstr "" 
     92 
     93#: root/templates/admin/votersimport.tt:13 root/templates/admin/votersimport.tt:14 
     94msgid "CSV file" 
     95msgstr "" 
     96 
    8597#: root/templates/admin/denied.tt:4 
    8698msgid "Cannot modify a started or finish poll" 
     
    159171msgstr "" 
    160172 
     173#: root/templates/admin/votersimport.tt:10 root/templates/admin/votersimport.tt:11 
     174msgid "Dummy" 
     175msgstr "" 
     176 
    161177#: root/templates/includes/ballot_form.tt:59 
    162178msgid "Empty ballot" 
     
    167183msgstr "" 
    168184 
     185#: root/templates/admin/votersimport.tt:48 
     186msgid "Enter here a comment to explain the password to use" 
     187msgstr "" 
     188 
    169189#: root/templates/admin/includes/ballot_decrypt.tt:8 
    170190msgid "Enter poll key here:" 
     
    205225#: root/templates/includes/ballot_form.tt:28 
    206226msgid "From voting list" 
     227msgstr "" 
     228 
     229#: root/templates/includes/poll_results.tt:49 
     230msgid "Id" 
     231msgstr "" 
     232 
     233#: root/templates/admin/votersimport.tt:51 
     234msgid "Import this list" 
    207235msgstr "" 
    208236 
     
    241269msgstr "" 
    242270 
     271#: root/templates/admin/votersimport.tt:16 root/templates/admin/votersimport.tt:17 
     272msgid "LDAP" 
     273msgstr "" 
     274 
    243275#: root/templates/admin/includes/poll_extra_settings.tt:9 
    244276msgid "Mail include ballot id" 
     
    305337msgstr "" 
    306338 
     339#: root/templates/includes/poll_results.tt:17 
     340msgid "Number of choice to retain:" 
     341msgstr "" 
     342 
     343#: root/templates/includes/poll_results.tt:30 
     344msgid "Number of empty ballot" 
     345msgstr "" 
     346 
    307347#: root/templates/admin/ballot.tt:22 
    308348msgid "Number of free input fields:" 
     349msgstr "" 
     350 
     351#: root/templates/includes/poll_results.tt:35 
     352msgid "Number of nul ballot" 
    309353msgstr "" 
    310354 
     
    338382msgstr "" 
    339383 
     384#: root/templates/includes/poll_results.tt:21 
     385msgid "Participation" 
     386msgstr "" 
     387 
    340388#: root/templates/newpoll/index.tt:27 
    341389msgid "Password" 
     
    359407msgstr "" 
    360408 
     409#: root/templates/includes/poll_results.tt:13 
     410msgid "Poll administrator must validate some ballot" 
     411msgstr "" 
     412 
    361413#: root/templates/admin/date.tt:124 
    362414msgid "Poll end:" 
     
    384436msgstr "" 
    385437 
     438#: root/templates/includes/poll_results.tt:90 
     439msgid "Results are not yet published" 
     440msgstr "" 
     441 
    386442#: root/templates/ballot/done.tt:16 root/templates/ballot/signed.tt:6 
    387443msgid "Results will be available" 
    388444msgstr "" 
    389445 
     446#: root/templates/includes/poll_results.tt:15 
     447msgid "Results:" 
     448msgstr "" 
     449 
    390450#: root/templates/admin/includes/poll_settings.tt:13 
    391451msgid "Rules:" 
     
    418478#: root/templates/admin/date.tt:44 
    419479msgid "Sunday" 
     480msgstr "" 
     481 
     482#: root/templates/includes/poll_results.tt:12 
     483msgid "Temporary results" 
    420484msgstr "" 
    421485 
     
    462526#: root/templates/admin/date.tt:46 
    463527msgid "Tuesday" 
     528msgstr "" 
     529 
     530#: root/templates/admin/votersimport.tt:47 
     531msgid "Use external authentication" 
    464532msgstr "" 
    465533 
     
    564632msgstr "" 
    565633 
     634#: root/templates/includes/poll_results.tt:54 
     635msgid "comment" 
     636msgstr "" 
     637 
    566638#: root/templates/admin/includes/poll_settings.tt:49 
    567639msgid "crypt the poll" 
     640msgstr "" 
     641 
     642#: root/templates/includes/poll_results.tt:50 
     643msgid "date (=> view as)" 
    568644msgstr "" 
    569645 
     
    585661msgstr "" 
    586662 
     663#: root/templates/importv/csv.tt:1 
     664msgid "format:" 
     665msgstr "" 
     666 
    587667#: root/templates/includes/signing_list.tt:23 
    588668msgid "has vote" 
     
    597677msgstr "" 
    598678 
    599 #: root/templates/admin/validate.tt:77 
     679#: root/templates/admin/validate.tt:82 
    600680msgid "input value" 
    601681msgstr "" 
     
    605685msgstr "" 
    606686 
     687#: root/templates/includes/poll_results.tt:76 
     688msgid "invalided" 
     689msgstr "" 
     690 
    607691#: root/templates/admin/validate.tt:56 
    608692msgid "is not valid" 
     
    617701msgstr "" 
    618702 
    619 #: root/templates/admin/validate.tt:75 
     703#: root/templates/admin/validate.tt:80 
    620704msgid "map ballot value" 
    621705msgstr "" 
     
    625709msgstr "" 
    626710 
    627 #: root/templates/admin/validate.tt:77 
     711#: root/templates/admin/validate.tt:82 
    628712msgid "must be see as" 
     713msgstr "" 
     714 
     715#: root/templates/includes/poll_results.tt:78 
     716msgid "must be validated" 
    629717msgstr "" 
    630718 
     
    633721msgstr "" 
    634722 
     723#: root/templates/includes/poll_results.tt:52 
     724msgid "not from list" 
     725msgstr "" 
     726 
     727#: root/templates/includes/poll_results.tt:49 
     728msgid "number" 
     729msgstr "" 
     730 
    635731#: root/templates/admin/voters.tt:59 
    636732msgid "password sent" 
    637733msgstr "" 
    638734 
     735#: root/templates/admin/validate.tt:74 
     736msgid "publish results" 
     737msgstr "" 
     738 
    639739#: root/mail/poll_reminder_voting.tt:26 
    640740msgid "running" 
     
    645745msgstr "" 
    646746 
     747#: root/templates/admin/votersimport.tt:33 
     748msgid "search..." 
     749msgstr "" 
     750 
     751#: root/templates/admin/votersimport.tt:20 
     752msgid "select" 
     753msgstr "" 
     754 
    647755#: root/templates/admin/voters.tt:30 
    648756msgid "send password" 
  • trunk/root/templates/admin/ballot.tt

    r296 r319  
    44[% poll = c.model('Vote').poll(voteid) %] 
    55 
    6 <div style="float: left; width: 55%" class="box"> 
    7 <form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    8 <table border=1> 
    9 <tr> 
    10 <td>[% l('Number of possible choice:') %]</td> 
    11 <td><input type="text" size="3" name="choice_count" value="[% c.req.param('choice_count') || poll.info('choice_count') | html %]"></td> 
    12 </tr> 
    13  
    14 <tr> 
    15 <td>[% l('Number of people to elect') %]<br> 
    16     ([% l('if different of number of choice') %]) 
    17 </td> 
    18 <td><input type="text" size="3" name="elected_count" value="[% c.req.param('elected_count') || poll.raw_info('elected_count') | html %]"></td> 
    19 </tr> 
    20  
    21 <tr> 
    22 <td>[% l('Number of free input fields:') %]</td> 
    23 <td><input type="text" size="3" name="free_choice" value="[% c.req.param('free_choice') || poll.info('free_choice') || 0 | html %]"></td> 
    24 </tr> 
    25  
    26 <tr> 
    27 <td>[% l('Number of people to elect, taken from voting list') %]</td> 
    28 <td><input type="text" size="3" name="elected_choice" value="[% c.req.param('elected_choice') || poll.info('elected_choice') || 0 | html %]"></td> 
    29 </tr> 
    30  
    31 </table> 
    32 <input type="submit" name="pollballot" value="[% l('save') %]"> 
    33 </form> 
     6[% INCLUDE 'includes/ballot_settings.tt' %] 
    347 
    358<hr> 
  • trunk/root/templates/admin/validate.tt

    r282 r319  
    7070 
    7171<div style="float:left; width: 40%;" class="box"> 
     72<div id="publish"> 
     73<form action="[% c.uri_for(poll.uid, 'validate') %]" method="POST"> 
     74<input type=submit name="publish" value="[% l('publish results') %]"> 
     75</form> 
     76</div> 
    7277[% FOREACH untrusted = poll.ballot_untrusted_values('noinvalid') %] 
    7378[% IF loop.first %] 
     
    7984<tr> 
    8085[% bl = [ poll.ballot_by_value(untrusted) ] %] 
    81 <td>[% untrusted | html %] [% bl.size %]</td> 
     86<td>[% untrusted | html %]</td> 
    8287<td> 
    8388    <form action="[% c.uri_for(poll.uid, 'validate') %]" method="POST"> 
  • trunk/root/templates/admin/votersimport.tt

    r315 r319  
    5353</div> 
    5454[% END %] 
    55 <p>[% voter.0 | html %]</p> 
     55<p>[% voter.0 | html %] 
     56[% voter.1 | html %] 
     57[% voter.2 | html %]</p> 
    5658[% END %] 
    5759</div> 
  • trunk/root/templates/includes/ballot_form.tt

    r298 r319  
    1111 
    1212<form action="[% b_form_url %]" method="POST"> 
    13 <p>Vous devez faire [% poll.info('choice_count') %] choix 
    14 [%- IF poll.info('choice_count') != poll.info('elected_count') -%] 
    15 pour [% poll.info('elected_count') %] élu(s)[%- END -%].</p> 
    1613 
    17 [% FOREACH key = poll.choices() %] 
    18 [% "<p>Candidats:</p>" IF loop.first %] 
    19 [% choice = poll.choice(key) %] 
    20 <input type="checkbox" name="sbal" value="[% key %]"[% " checked" IF sbal.$key %]> 
    21 [% choice.info.label | html %]<br> 
    22 [% END %] 
     14[% ballottt = 'pollinc/' _ poll.type _ '/ballot.tt' %] 
     15[% INCLUDE $ballottt %] 
    2316 
    24 [% count = 0 %] 
    25 [% IF poll.voting_keys.size %] 
    26 [% WHILE count < (poll.info('elected_choice') || 0) %] 
    27 [% IF count == 0 %] 
    28 <p>[% l('From voting list') %]</p> 
    29 [% END %] 
    30 [% FOREACH vkey = poll.voting_keys %] 
    31 [% voting = poll.voting(vkey) %] 
    32 [% '<select name="esbal"><option value=""></option>' IF loop.first %] 
    33 <option value="[% voting.info.label || voting.info.mail | html %]" 
    34     [% " selected" IF esbal.$count == (voting.info.label || voting.info.mail) %]> 
    35     [% voting.info.label || voting.info.mail | html %] 
    36 </option> 
    37 [% '</select><br>' IF loop.last %] 
    38 [% END %] 
    39 [% count = count + 1 %] 
    40 [% END %] 
    41 [% ELSE %] 
    42 <p>[% l('No voter to show') %]</p> 
    43 [% END %] 
    44  
    45  
    46 [% count = 0 %] 
    47 [% WHILE count < poll.info('free_choice') %] 
    48 [% IF count == 0 %] 
    49 <p>[% l('Free choice') %]</p> 
    50 [% END %] 
    51 <input type="text" name="fsbal" value="[% fsbal.$count %]"><br> 
    52 [% count = count + 1 %] 
    53 [% END %] 
    5417<br> 
    5518<input type="submit" name="ballot" value="[% l('Vote') _ ' ' %] &gt;&gt;"> 
  • trunk/root/templates/includes/ballot_settings.tt

    r315 r319  
    11<!-- $Id$ --> 
    2 [% INCLUDE 'includes/admin_menu.tt' %] 
    3  
    42[% poll = c.model('Vote').poll(voteid) %] 
    53 
    64<div style="float: left; width: 55%" class="box"> 
    75<form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    8 <table border=1> 
    9 <tr> 
    10 <td>[% l('Number of possible choice:') %]</td> 
    11 <td><input type="text" size="3" name="choice_count" value="[% c.req.param('choice_count') || poll.info('choice_count') | html %]"></td> 
    12 </tr> 
    136 
    14 <tr> 
    15 <td>[% l('Number of people to elect') %]<br> 
    16     ([% l('if different of number of choice') %]) 
    17 </td> 
    18 <td><input type="text" size="3" name="elected_count" value="[% c.req.param('elected_count') || poll.raw_info('elected_count') | html %]"></td> 
    19 </tr> 
     7[% ballotsettingstt = 'pollinc/' _ poll.type _ '/ballot_settings.tt' %] 
     8[% INCLUDE $ballotsettingstt %] 
    209 
    21 <tr> 
    22 <td>[% l('Number of free input fields:') %]</td> 
    23 <td><input type="text" size="3" name="free_choice" value="[% c.req.param('free_choice') || poll.info('free_choice') || 0 | html %]"></td> 
    24 </tr> 
    25  
    26 <tr> 
    27 <td>[% l('Number of people to elect, taken from voting list') %]</td> 
    28 <td><input type="text" size="3" name="elected_choice" value="[% c.req.param('elected_choice') || poll.info('elected_choice') || 0 | html %]"></td> 
    29 </tr> 
    30  
    31 </table> 
    3210<input type="submit" name="pollballot" value="[% l('save') %]"> 
    3311</form> 
    3412 
    35 <hr> 
    36  
    37 [% IF ! poll.choices_keys.size %] 
    38 <p class="alert">[% l('No choice are configured') %]</p> 
    39 [% ELSE %] 
    40 [% FOREACH choicek = poll.choices_keys %] 
    41 [% choice = poll.choice(choicek) %] 
    42 <form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    43 [% loop.count %] - [% choice.info.label | html %] 
    44 <input type="hidden" name="delch" value="[% choicek %]"> 
    45 <input type="submit" name="del" value="[% l('delete') %]"> 
    46 </form> 
    47 <br> 
    48 [% END %] 
    49 [% END %] 
    50 <form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    51 [% l('Add a choice') %]<br> 
    52 <input type="text" name="addch"> 
    53 <input type="submit" value="[% l('Add') %]"> 
    54 </form> 
    55 </div> 
    56  
    57 <div style="float: right; width: 30%" class="ballot"> 
    58 <p>[% l('Preview of ballot') %]</p> 
    59 [% INCLUDE 'includes/ballot_form.tt' b_form_url = c.uri_for(poll.uid, 'ballot') %] 
    60 </div> 
    61  
    62 <div style="clear: both"></div> 
  • trunk/root/templates/includes/poll_results.tt

    r315 r319  
    1818 
    1919<table border="1"> 
    20 <tr><td>[% l('Participation') %]</td><td>[% poll.signing_count %]</td><td>[% poll.signing_count / poll.voting_count * 100 | format('%.2f %%') IF poll.voting_count %]</td></tr> 
    21 <tr><td>[% l('Ballot Number') %]</td><td>[% poll.ballot_count %]</td><td></td></tr> 
    22 <tr><td>[% l('Number of empty ballot') %]</td><td>[% poll.empty_ballot_count %]</td><td>[% poll.empty_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td></tr> 
    23 <tr><td>[% l('Number of nul ballot') %]</td><td>[% poll.invalid_ballot_count %]</td><td>[% poll.invalid_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td></tr> 
    24 <tr><td>[% l('Number of voices') %]</td><td>[% poll.voices_ballot_count %]</td><td>[% poll.voices_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td></tr> 
     20<tr> 
     21    <td>[% l('Participation') %]</td> 
     22    <td>[% poll.signing_count %]</td> 
     23    <td>[% poll.signing_count / poll.voting_count * 100 | format('%.2f %%') IF poll.voting_count %]</td> 
     24</tr> 
     25<tr> 
     26    <td>[% l('Ballots count') %]</td> 
     27    <td>[% poll.ballots_count %]</td> 
     28    <td></td></tr> 
     29<tr> 
     30    <td>[% l('Number of empty ballot') %]</td> 
     31    <td>[% poll.empty_ballot_count %]</td> 
     32    <td>[% poll.empty_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td> 
     33</tr> 
     34<tr> 
     35    <td>[% l('Number of nul ballot') %]</td> 
     36    <td>[% poll.invalid_ballot_count %]</td> 
     37    <td>[% poll.invalid_ballot_count / poll.ballots_count * 100 | format('%.2f %%') IF poll.ballots_count %]</td> 
     38</tr> 
    2539</table> 
    2640 
    27 [% IF poll.ballot_count_nonull %] 
    28 [% FOREACH res = poll.results %] 
    29 [% IF loop.first %] 
    30 <p>[% l('Score:') %]</p> 
    31 <table border="1"><tr> 
    32 <th>[% l('Legend:') %]</th> 
    33 <td class="majabs">[% l('Absolute Majority') %]</td> 
    34 <td class="selected">[% l('Elected') %]</td> 
    35 <td class="notselected">l('Not elected') %]</td> 
    36 </tr></table><br> 
    37 <table border="1"> 
    38 <tr><th>Score</th><th>[% l('Line n°') %]</th><th>[% l('choice') %]</th><th>[% 
    39 l('Number of voice') %]</th><th>[% l('%') %]</th><th></th></tr> 
    40 [% END %] 
    41  
    42 [% IF res.elected %] 
    43 [% IF res.abs_maj %] 
    44 [% class = 'majabs' %] 
    45 [% ELSE %] 
    46 [% class = 'selected' %] 
    47 [% END %] 
    48 [% ELSE %] 
    49 [% class = 'notselected' %] 
    50 [% END %] 
    51 <tr class="[% class %]"> 
    52 <td>[% res.order %]</td> 
    53 <td>[% loop.count %]</td> 
    54 <td>[% res.value | html %]</td> 
    55 <td>[% res.count %]</td> 
    56 <td>[% res.count * 100 / poll.ballot_count_nonull | format('%.2f') %]</td> 
    57 <td><img src="[% c.uri_for('/static', 'images', 'green-v.png') %]"  
    58 height="10px" width="[% res.count * 400 / poll.ballot_count_nonull | format('%d') %]px"></td> 
    59 </tr> 
    60  
    61 [% IF loop.last %] 
    62 </table> 
    63 [% END %] 
    64 [% END %] 
    65 [% ELSE %] 
    66 <p class="alert">[% l('No results') %]</p> 
    67 [% END %] 
    68 </div> 
     41[% resultstt = 'pollinc/' _ poll.type _ '/results.tt' %] 
     42[% INCLUDE $resultstt %] 
    6943 
    7044[% FOREACH id = poll.ballot_keys %] 
  • trunk/root/templates/pollinc/binary/ballot.tt

    r315 r319  
    22[% poll = c.model('Vote').poll(voteid) %] 
    33 
    4 [% IF poll.info('procedure') %] 
    5 [% poll.info('procedure') | html %] 
    6 <hr> 
    7 [% ELSIF poll.info('description') %] 
    8 [% poll.info('description') | html %] 
    9 <hr> 
    10 [% END %] 
    11  
    12 <form action="[% b_form_url %]" method="POST"> 
    134<p>Vous devez faire [% poll.info('choice_count') %] choix 
    145[%- IF poll.info('choice_count') != poll.info('elected_count') -%] 
     
    4334[% END %] 
    4435 
    45  
    4636[% count = 0 %] 
    4737[% WHILE count < poll.info('free_choice') %] 
     
    5242[% count = count + 1 %] 
    5343[% END %] 
    54 <br> 
    55 <input type="submit" name="ballot" value="[% l('Vote') _ ' ' %] &gt;&gt;"> 
    56 </form> 
    57 <hr> 
    58 <form action="[% b_form_url %]" method="POST"> 
    59 <input type="submit" name="ballot" value="[% l('Empty ballot') _ ' ' %] &gt;&gt;"> 
    60 </form> 
  • trunk/root/templates/pollinc/binary/ballot_settings.tt

    r315 r319  
    11<!-- $Id$ --> 
    2 [% INCLUDE 'includes/admin_menu.tt' %] 
    3  
    42[% poll = c.model('Vote').poll(voteid) %] 
    53 
    6 <div style="float: left; width: 55%" class="box"> 
    7 <form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    84<table border=1> 
    95<tr> 
     
    3026 
    3127</table> 
    32 <input type="submit" name="pollballot" value="[% l('save') %]"> 
    33 </form> 
    34  
    35 <hr> 
    36  
    37 [% IF ! poll.choices_keys.size %] 
    38 <p class="alert">[% l('No choice are configured') %]</p> 
    39 [% ELSE %] 
    40 [% FOREACH choicek = poll.choices_keys %] 
    41 [% choice = poll.choice(choicek) %] 
    42 <form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    43 [% loop.count %] - [% choice.info.label | html %] 
    44 <input type="hidden" name="delch" value="[% choicek %]"> 
    45 <input type="submit" name="del" value="[% l('delete') %]"> 
    46 </form> 
    47 <br> 
    48 [% END %] 
    49 [% END %] 
    50 <form action="[% c.uri_for(poll.uid, 'ballot') %]" method="POST"> 
    51 [% l('Add a choice') %]<br> 
    52 <input type="text" name="addch"> 
    53 <input type="submit" value="[% l('Add') %]"> 
    54 </form> 
    55 </div> 
    56  
    57 <div style="float: right; width: 30%" class="ballot"> 
    58 <p>[% l('Preview of ballot') %]</p> 
    59 [% INCLUDE 'includes/ballot_form.tt' b_form_url = c.uri_for(poll.uid, 'ballot') %] 
    60 </div> 
    61  
    62 <div style="clear: both"></div> 
  • trunk/root/templates/pollinc/binary/results.tt

    r315 r319  
    11<!-- $Id$ --> 
    2 [% poll = c.model('Vote').results(voteid) %] 
     2[% poll = c.model('Vote').poll(voteid) %] 
    33 
    4 [% IF poll.can_show_result %] 
    5  
    6 <div id="results" class="box"> 
    7 <div style="float: right"> 
    8 <p><a href="[% c.uri_for('/vote', poll.uid, 'results.pdf') %]">Résultat en PDF</a></p> 
    9 <p><a href="[% c.uri_for('/vote', poll.uid, 'report.pdf') %]">Rapport en PDF</a></p> 
    10 </div> 
    11 [% IF poll.list_ballot_needvalid.size %] 
    12 <p>[% l('Temporary results') %]</p> 
    13 <p class="alert">[% l('Poll administrator must validate some ballot') %]</p> 
    14 [% ELSE %] 
    15 <p>[% l('Results:') %]</p> 
    16 [% END %] 
    17 <p>[% l('Number of choice to retain:') _ ' ' %][% poll.info('choice_count') %]</p> 
    18  
    19 <table border="1"> 
    20 <tr><td>[% l('Participation') %]</td><td>[% poll.signing_count %]</td><td>[% poll.signing_count / poll.voting_count * 100 | format('%.2f %%') IF poll.voting_count %]</td></tr> 
    21 <tr><td>[% l('Ballot Number') %]</td><td>[% poll.ballot_count %]</td><td></td></tr> 
    22 <tr><td>[% l('Number of empty ballot') %]</td><td>[% poll.empty_ballot_count %]</td><td>[% poll.empty_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td></tr> 
    23 <tr><td>[% l('Number of nul ballot') %]</td><td>[% poll.invalid_ballot_count %]</td><td>[% poll.invalid_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td></tr> 
    24 <tr><td>[% l('Number of voices') %]</td><td>[% poll.voices_ballot_count %]</td><td>[% poll.voices_ballot_count / poll.ballot_count * 100 | format('%.2f %%') IF poll.ballot_count %]</td></tr> 
    25 </table> 
    26  
    27 [% IF poll.ballot_count_nonull %] 
     4[% IF poll.results %] 
    285[% FOREACH res = poll.results %] 
    296[% IF loop.first %] 
     
    3310<td class="majabs">[% l('Absolute Majority') %]</td> 
    3411<td class="selected">[% l('Elected') %]</td> 
    35 <td class="notselected">l('Not elected') %]</td> 
     12<td class="notselected">[% l('Not elected') %]</td> 
    3613</tr></table><br> 
    3714<table border="1"> 
     
    5431<td>[% res.value | html %]</td> 
    5532<td>[% res.count %]</td> 
    56 <td>[% res.count * 100 / poll.ballot_count_nonull | format('%.2f') %]</td> 
    57 <td><img src="[% c.uri_for('/static', 'images', 'green-v.png') %]"  
    58 height="10px" width="[% res.count * 400 / poll.ballot_count_nonull | format('%d') %]px"></td> 
     33<td>[% res.count * 100 / poll.voices_ballot_count | format('%.2f') %]</td> 
     34<td><img src="[% c.uri_for('/static', 'images', 'green-v.png') %]" height="10px" width="[% res.count * 400 / poll.voices_ballot_count | format('%d') %]px"></td> 
    5935</tr> 
    6036 
     
    6844</div> 
    6945 
    70 [% FOREACH id = poll.ballot_keys %] 
    71 [% IF loop.first %] 
    72 <div id="ballot_list" class="box"> 
    73 <p>[% l('Ballot list:') %]</p> 
    74 <table border="1"> 
    75 <tr><th>[% l('number') %]</th><th>[% l('Id') %]</th> 
    76 <th>[% l('date (=> view as)') | html %] 
    77 [% IF poll.info('free_choice') %] 
    78 <br>(*: [% l('not from list') %]) 
    79 [% END %] 
    80 </th><th>[% l('comment') %]</th></tr> 
    81 [% END %] 
    82 <tr> 
    83 <td>[% loop.count %]</td> 
    84 <td><pre>[% id | html %]</pre></td> 
    85 <td> 
    86 [% items = poll.ballot(id).items %] 
    87 [% IF items.size %] 
    88 [% FOREACH item = items %] 
    89 [% "<ul>\n" IF loop.first %] 
    90 <li>[% item.v | html %] 
    91 [% ' *' IF NOT item.fromlist %] 
    92 [% IF item.corrected %] (=&gt; [% item.corrected %])[% END %]</li> 
    93 [% "</ul>\n" IF loop.last %] 
    94 [% END %] 
    95 [% ELSE %] 
    96 <i>Vote blanc</i> 
    97 [% END %] 
    98 </td> 
    99 <td> 
    100 [% invalid = '#' _ poll.ballot(id).info.invalid %] 
    101 [% IF invalid == '#1' %] 
    102 <span class="alert">[% l('invalided') %]</span> 
    103 [% ELSIF invalid  == '#' %] 
    104 <i>[% l('must be validated') %]</i> 
    105 [% END %] 
    106 </td> 
    107 </tr> 
    108 [% IF loop.last %] 
    109 </table> 
    110 </div> 
    111 [% END %] 
    112 [% END %] 
    113  
    114 [% ELSE %][% # can show result %] 
    115 <div class="page_box"> 
    116 <p>[% l('Results are not yet published') %]<p> 
    117 </div> 
    118 [% END %] 
  • trunk/t/10Epoll_DB.t

    r309 r319  
    2525            my ($r) = @_; 
    2626            is($r->absolute_majority, 1, "Can get absolute_majority"); 
    27             is($r->ballot_count, 0, "can get ballot count"); 
     27            is($r->ballots_count, 0, "can get ballot count"); 
    2828            is($r->voting_count, 0, "can get voting count"); 
    2929            is($r->signing_count, 0, "can get signing count"); 
     
    4444            my ($r) = @_; 
    4545            is($r->absolute_majority, 2, "Can get absolute_majority"); 
    46             is($r->ballot_count, 4, "can get ballot count"); 
    47             is($r->ballot_count_nonull, 3, "can get ballot count"); 
     46            is($r->ballots_count, 4, "can get ballot count"); 
     47            is($r->_voices_ballot_count, 3, "can get ballot count"); 
    4848            is($r->voting_count, 6, "can get voting count"); 
    4949            is($r->signing_count, 4, "can get signing count"); 
     
    6363            f => {}, 
    6464        }, 
     65        map_values => sub { 
     66            my ($r) = @_; 
     67            $r->map_value('ch10', 'ch1'); 
     68        }, 
    6569        test_count => 14, 
    6670        tests => sub { 
    6771            my ($r) = @_; 
    68             $r->map_value('ch10', 'ch1'); 
    6972            is($r->absolute_majority, 2, "Can get absolute_majority"); 
    70             is($r->ballot_count, 4, "can get ballot count"); 
     73            is($r->ballots_count, 4, "can get ballot count"); 
    7174            is($r->not_empty_ballot_count, 3, "can get ballot count"); 
    7275            is($r->empty_ballot_count, 1, "can get empty ballot count"); 
     
    102105            my ($r) = @_; 
    103106            is($r->absolute_majority, 3, "Can get absolute_majority"); 
    104             is($r->ballot_count, 5, "can get ballot count"); 
     107            is($r->ballots_count, 5, "can get ballot count"); 
    105108            is($r->not_empty_ballot_count, 3, "can get ballot count"); 
    106109            is($r->empty_ballot_count, 2, "can get empty ballot count"); 
     
    121124plan tests =>  
    122125    3                          # Fixed test  
    123     + scalar(@$test_polls) * 7 # number of tested polls scenario 
    124     + $poll_test_count * 2;    # poll test 
     126    + scalar(@$test_polls) * 8 # number of tested polls scenario 
     127    + $poll_test_count;    # poll test 
    125128 
    126129use_ok 'Epoll', 'Epoll'; 
     
    160163        ); 
    161164    } 
     165 
     166    if ($tpoll->{map_values}) { 
     167        $tpoll->{map_values}->($poll); 
     168    } 
    162169     
    163170    isa_ok(my $results = $vote->results($pollid), 'Epoll::DB::Poll'); 
    164171 
    165     $tpoll->{tests}->($results); 
    166  
    167     ok($results->delete_ballots, "Can switch to static results"); 
     172    ok($results->decrypted_ballots(), "Can decrypt ballot"); 
     173    ok($results->compute_results(), "Can compute results"); 
    168174 
    169175    $tpoll->{tests}->($results); 
  • trunk/t/15ImportV.t

    r315 r319  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 1; 
     3use Test::More tests => 2; 
    44 
    55use_ok('Epoll::DB::ImportV'); 
     
    88    "Can instanciate dummy import"); 
    99 
    10 warn $import->auth_type; 
    11 warn $import->can_authenticate; 
    12  
    1310$import->{params}{foo} = 1; 
    1411$import->{params}{bar} = 1; 
    1512 
    16 warn $import->xml_params; 
    17 $import->load_xml_params($import->xml_params); 
    18 $import->load_xml_params($import->xml_params); 
    19  
    20 warn join ' ', keys %{$import->{params}}; 
  • trunk/t/20Epoll_Web.t

    r309 r319  
    3636    "Request /admin/$pollid/ballot should succeed" ); 
    3737 
    38 ok( request("/ballot/$pollid")->is_success, "Request /admin/$pollid should succeed" ); 
     38ok( request("/admin/$pollid?vpass$pollid=password")->is_success, "Request /admin/$pollid should succeed" ); 
    3939ok( request("/ballot/$pollid?mail=user@;password=$votingpass")->is_success, 
    40     "Request /admin/$pollid should succeed" ); 
     40    "Request /ballot/$pollid should succeed" ); 
    4141 
    4242# Be sure today is included: 
     
    5656    "Request /admin/$pollid/ballot should succeed" ); 
    5757 
    58 ok( request("/ballot/$pollid")->is_success, "Request /admin/$pollid should succeed" ); 
    59 ok( request("/ballot/$vote_uid")->is_success, "Request /admin/$vote_uid should succeed" ); 
     58ok( request("/ballot/$pollid")->is_success, "Request /ballot/$pollid should succeed" ); 
     59ok( request("/ballot/$vote_uid")->is_success, "Request /ballot/$vote_uid should succeed" ); 
    6060ok( request("/ballot/$pollid?mail=user@;password=$votingpass")->is_success, 
    61     "Request /admin/$pollid should succeed" ); 
     61    "Request /ballot/$pollid should succeed" ); 
    6262 
    6363 
Note: See TracChangeset for help on using the changeset viewer.