Changeset 42


Ignore:
Timestamp:
03/16/09 18:57:18 (15 years ago)
Author:
nanardon
Message:
  • html and perl fixes
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/Controller/Admin.pm

    r39 r42  
    6565                and $vote->db->commit; 
    6666        } elsif ($c->req->param('mail')) { 
    67             $vote->addupd_voting($id, $c->req->param('id'), $c->req->param('mail')) 
     67            $vote->addupd_voting($id, $c->req->param('mail'), $c->req->param('id')) 
    6868                and $vote->db->commit; 
    6969        } elsif($c->req->param('mailpasswd')) { 
  • trunk/lib/Vote/Model/Vote.pm

    r38 r42  
    458458        q{ 
    459459        select count(*) from ballot where poll = ? 
    460         and id in (select id from ballot_item) and invalid = 'false' 
     460        and id in (select id from ballot_item) and 
     461        (invalid = 'false' or invalid is null) 
    461462        } 
    462463    ); 
     
    486487 
    487488    $vinfo->{password} or return; 
    488     warn $vinfo->{password}; 
    489489    if (crypt($passwd, $vinfo->{password} || '') eq $vinfo->{password}) { 
    490490        return 1; 
     
    537537    my $sth = $self->db->prepare( 
    538538        q{ 
    539         select count(ballot.id), value from ballot join ballot_item 
    540         on ballot.id = ballot_item.id where ballot.poll = ? and invalid = 'false' 
    541         group by value 
     539        select count(ballot.id), coalesce(corrected, value) as value 
     540        from ballot join ballot_item 
     541        on ballot.id = ballot_item.id where ballot.poll = ? and 
     542        (invalid = 'false' or invalid is null) 
     543        group by coalesce(corrected, value) 
    542544        order by count desc 
    543545        } 
     
    622624} 
    623625 
     626sub vote_ballot_untrusted_values { 
     627    my ($self, $voteid) = @_; 
     628 
     629    my $getval = $self->db->prepare_cached( 
     630        q{ 
     631        select value from ballot join ballot_item 
     632        on ballot.id = ballot_item.id 
     633        where poll = ? and fromlist = false 
     634        group by value order by value 
     635        } 
     636    ); 
     637    $getval->execute($voteid); 
     638    my @vals; 
     639    while (my $res = $getval->fetchrow_hashref) { 
     640        push(@vals, $res->{value}); 
     641    } 
     642    @vals 
     643} 
     644 
     645sub vote_ballot_values { 
     646    my ($self, $voteid) = @_; 
     647 
     648    my $getval = $self->db->prepare_cached( 
     649        q{ 
     650        select value from ballot join ballot_item 
     651        on ballot.id = ballot_item.id 
     652        where poll = ? 
     653        group by value order by value 
     654        } 
     655    ); 
     656    $getval->execute($voteid); 
     657    my @vals; 
     658    while (my $res = $getval->fetchrow_hashref) { 
     659        push(@vals, $res->{value}); 
     660    } 
     661    @vals 
     662} 
     663 
     664sub vote_map_value { 
     665    my ($self, $voteid, $from, $to) = @_; 
     666 
     667    my $sth = $self->db->prepare_cached( 
     668        q{ 
     669        update ballot_item set corrected = ? where 
     670        id in (select id from ballot where poll = ?) 
     671        and value = ? 
     672        } 
     673    ); 
     674 
     675    $sth->execute($to, $voteid, $from) or $self->db->rollback; 
     676    $self->db->commit; 
     677} 
     678 
    624679sub addupd_voting { 
    625680    my ($self, $voteid, $mail, $id) = @_; 
     
    631686    ); 
    632687 
    633     if ($upd->execute($mail, $voteid, $id) == 0) { 
     688    if ($upd->execute($id, $mail, $voteid) == 0) { 
    634689        my $add = $self->db->prepare_cached(q{ 
    635690            insert into voting (poll, label, mail) values (?,?,?) 
  • trunk/root/templates/admin/default.tt

    r34 r42  
    8787[% FOREACH bid = vote.list_vote_ballot_needvalid(voteid) %] 
    8888    [% IF loop.first %] 
     89    <div id="ballot_to_valid"> 
     90    <p>Bulletins à valider</p> 
    8991    <form action="[% c.uri_for(voteid) %]"> 
    9092    <table border="1"> 
     
    9395<td>[% bid %]</td> 
    9496<td> 
    95 [% FOREACH item = [ vote.ballot_items(bid) ] %] 
    96 [% item.v %]<br> 
     97[% FOREACH item = vote.ballot_items(bid) %] 
     98[% loop.count %]- [% item.v %]<br> 
    9799[% END %] 
    98100</td> 
     
    106108    <input type="submit"> 
    107109    </form> 
     110    </div> 
    108111    [% END %] 
    109112[% END %] 
  • trunk/root/templates/ballot/closed.tt

    r18 r42  
    1 Ce vote est clos. 
     1[% INCLUDE 'includes/poll.tt' %] 
     2 
     3[% vote = c.model('Vote') %] 
     4 
     5<div id="ballot"> 
     6[% IF vote.vote_status(voteid) == 'BEFORE' %] 
     7Ce Vote n'est pas encore ouvert 
     8[% ELSIF vote.vote_status(voteid) == 'AFTER' %] 
     9Ce vote est terminé, les résultats sont disponibles 
     10<a href="[% c.uri_for('/vote', voteid) %]">ici</a>. 
     11[% END %] 
     12</div> 
Note: See TracChangeset for help on using the changeset viewer.