Changeset 307


Ignore:
Timestamp:
05/21/10 18:19:22 (10 years ago)
Author:
nanardon
Message:
  • add a new config option making poll creation limit by admin password instead mail confirmation (from branche/1)
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/README

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/epoll.yml.example

    r248 r307  
    66# The smtp serveur to use, default is localhost 
    77smtp: 
     8# This change the poll creation behavior, instead ask want confirmation by mail 
     9# it ask for this password (in clear) 
     10# newpollpasswd: 
  • trunk/lib/Epoll/Controller/Newpoll.pm

    r257 r307  
    3333    $c->stash->{page}{title} = 'Créer un nouveau vote'; 
    3434    if ($c->req->param('mail')) { 
    35         my $reqid = $c->model('Vote')->create_poll_request( 
    36             mail => $c->req->param('mail'), 
    37             label => $c->req->param('label'), 
    38         ); 
    39         $c->forward( 
    40             q'Epoll::View::Mail', 'render', 
    41             [ 'poll_request.tt', { 
    42                 To => $c->req->param('mail'), 
    43                 Subject => "New poll request", 
    44                 mail => { 
    45                     label => $c->req->param('label'), 
    46                     reqid => $reqid, 
     35        if ($c->config->{newpollpasswd}) { 
     36            if (($c->req->param('passwd') || '') eq $c->config->{newpollpasswd}) 
     37                { 
     38                    if (my $pid = $c->model('Vote')->create_poll( 
     39                            $c->req->param('label'), 
     40                            $c->req->param('mail'), 
     41                            $c->req->param('vpasswd'), 
     42                        ) 
     43                    ) { 
     44                        $c->session->{'vpass' . $pid} = $c->req->param('vpasswd'); # avoid auth on admin page 
     45                        $c->res->redirect($c->uri_for('/admin', 
     46                                $c->model('Vote')->poll_id_from_uid($pid)) 
     47                        ); 
     48                    } 
     49                } else { 
     50                    $c->stash->{passwderror} = 1; 
    4751                } 
    48             } ] 
    49         ); 
    50  
    51         $c->stash->{template} = 'newpoll/request.tt'; 
     52        } else { 
     53            my $reqid = $c->model('Vote')->create_poll_request( 
     54                mail => $c->req->param('mail'), 
     55                label => $c->req->param('label'), 
     56            ); 
     57            $c->forward( 
     58                q'Epoll::View::Mail', 'render', 
     59                [ 'poll_request.tt', { 
     60                    To => $c->req->param('mail'), 
     61                    Subject => "New poll request", 
     62                    mail => { 
     63                        label => $c->req->param('label'), 
     64                        reqid => $reqid, 
     65                    } 
     66                } ] 
     67            ); 
     68            $c->stash->{template} = 'newpoll/request.tt'; 
     69        } 
    5270    } 
    5371 
  • trunk/lib/Epoll/DB.pm

    r303 r307  
    158158    my $rinfo = $self->poll_request_info($rid) or return; 
    159159 
    160     my $pollid = $self->create_poll($rinfo->{mail}, $rinfo->{label}, $passwd); 
     160    my $pollid = $self->_create_poll($rinfo->{mail}, $rinfo->{label}, $passwd); 
    161161     
    162162    my $delreq = $self->db->prepare_cached( 
     
    170170 
    171171sub create_poll { 
     172    my ($self, @args) = @_; 
     173    my $uid = $self->_create_poll(@args); 
     174    $self->commit; 
     175    $uid; 
     176} 
     177 
     178sub _create_poll { 
    172179    my ($self, $mail, $label, $passwd) = @_; 
    173180 
     
    191198        return; 
    192199    }; 
    193  
    194200 
    195201    $newpollid 
  • trunk/lib/Epoll/I18N/fr.po

    r301 r307  
    221221"à participer à ce vote ?" 
    222222 
     223#: root/templates/newpoll/index.tt:21 
     224#, fuzzy 
     225msgid "Invalid site password:" 
     226msgstr "envoyer les mots de passe" 
     227 
    223228#: root/templates/admin/date.tt:31 
    224229msgid "Jan" 
     
    343348msgstr "A participé" 
    344349 
    345 #: root/templates/newpoll/index.tt:12 
     350#: root/templates/newpoll/index.tt:27 
    346351msgid "Password" 
    347352msgstr "Mot de passe" 
     353 
     354#: root/templates/newpoll/index.tt:16 
     355#, fuzzy 
     356msgid "Password of this poll:" 
     357msgstr "Oui, détruire ce vote" 
    348358 
    349359#: root/templates/ballot/login.tt:17 
     
    368378msgstr "Le vote est en cours" 
    369379 
    370 #: root/templates/newpoll/index.tt:10 
     380#: root/templates/newpoll/index.tt:12 
    371381msgid "Poll name:" 
    372382msgstr "Nom du vote:" 
     
    408418msgid "September" 
    409419msgstr "Septembre" 
     420 
     421#: root/templates/newpoll/index.tt:24 
     422#, fuzzy 
     423msgid "Site password:" 
     424msgstr "envoyer les mots de passe" 
    410425 
    411426#: root/templates/admin/includes/ballot_validation.tt:8 
  • trunk/lib/Epoll/I18N/messages.pot

    r301 r307  
    217217msgstr "" 
    218218 
     219#: root/templates/newpoll/index.tt:21 
     220msgid "Invalid site password:" 
     221msgstr "" 
     222 
    219223#: root/templates/admin/date.tt:31 
    220224msgid "Jan" 
     
    338342msgstr "" 
    339343 
    340 #: root/templates/newpoll/index.tt:12 
     344#: root/templates/newpoll/index.tt:27 
    341345msgid "Password" 
     346msgstr "" 
     347 
     348#: root/templates/newpoll/index.tt:16 
     349msgid "Password of this poll:" 
    342350msgstr "" 
    343351 
     
    363371msgstr "" 
    364372 
    365 #: root/templates/newpoll/index.tt:10 
     373#: root/templates/newpoll/index.tt:12 
    366374msgid "Poll name:" 
    367375msgstr "" 
     
    402410#: root/templates/admin/date.tt:25 
    403411msgid "September" 
     412msgstr "" 
     413 
     414#: root/templates/newpoll/index.tt:24 
     415msgid "Site password:" 
    404416msgstr "" 
    405417 
  • trunk/root/templates/newpoll/index.tt

    r285 r307  
    77<table border="0"> 
    88<tbody align="center"> 
    9 <tr><th>[% l('Your mail:') %]</th><td><input type="text" name="mail" tabindex="1" size="45" maxlength="150"></td></tr> 
    10 <tr><th>[% l('Poll name:') %]</th><td><input type="text" name="label" tabindex="2" size="45" maxlength="150"></td></tr> 
     9<tr><th>[% l('Your mail:') %]</th><td> 
     10  <input type="text" name="mail" value="[% c.req.param('mail') | html %]" tabindex="1" size="45" maxlength="150"> 
     11</td></tr> 
     12<tr><th>[% l('Poll name:') %]</th><td> 
     13  <input type="text" name="label" value="[% c.req.param('label') | html %]" tabindex="2" size="45" maxlength="150"> 
     14</td></tr> 
     15[% IF c.config.newpollpasswd %] 
     16<tr><th>[% l('Password of this poll:') %]</th><td> 
     17  <input type="password" name="vpasswd" value="[% c.req.param('vpasswd') | html %]"  tabindex="3"> 
     18</td></tr> 
     19[% IF passwderror %] 
     20<tr><td colspan="2" class="alert"> 
     21    [% l('Invalid site password:') %] 
     22</td></tr> 
     23[% END %] 
     24<tr><th>[% l('Site password:') %]</th><td><input type="password" name="passwd" tabindex="4"></td></tr> 
     25[% END %] 
    1126<!-- Cf http://forge.ipsl.jussieu.fr/epoll/ticket/1 
    1227<tr><th>[% l('Password') %]</th><td><input type="password" name="vpasswd"></td></tr> 
Note: See TracChangeset for help on using the changeset viewer.