Browse Source

fix vote termination

Julien Moutinho 10 years ago
parent
commit
686111838d
2 changed files with 4 additions and 3 deletions
  1. 3 3
      main.py
  2. 1 0
      templates/admin_vote_edit.html

+ 3 - 3
main.py

@@ -432,9 +432,9 @@ def votes(votes):
                  left join (' + nb_votes + ') on id = id_vote'
                  left join (' + nb_votes + ') on id = id_vote'
     basequery = 'select *, votes.id as voteid, groups.name as groupname from (' + basequery + ') as votes \
     basequery = 'select *, votes.id as voteid, groups.name as groupname from (' + basequery + ') as votes \
                  join groups on groups.id = id_group \
                  join groups on groups.id = id_group \
-                 where is_open=1 and is_hidden=0'
+                 where is_hidden=0'
     if votes == 'all':
     if votes == 'all':
-        votes = query_db(basequery + ' order by date_end')
+        votes = query_db(basequery + ' and is_open=1 order by date_end')
     elif votes == 'archive':
     elif votes == 'archive':
         votes = query_db(basequery + ' and is_terminated=1 order by date_end desc')
         votes = query_db(basequery + ' and is_terminated=1 order by date_end desc')
     elif votes == 'current':
     elif votes == 'current':
@@ -816,7 +816,7 @@ def admin_vote_edit(voteid):
     choices = query_db('select * from choices where id_vote = ?', [voteid])
     choices = query_db('select * from choices where id_vote = ?', [voteid])
     values_ = query_db('select * from cardinals where id = ?', [vote['id_cardinal']], one=True)['name']
     values_ = query_db('select * from cardinals where id = ?', [vote['id_cardinal']], one=True)['name']
     attachments = query_db('select * from attachments where id_vote = ?', [voteid])
     attachments = query_db('select * from attachments where id_vote = ?', [voteid])
-    if date.today().strftime("%Y-%m-%d") > vote['date_end']:
+    if date.today().strftime("%Y-%m-%d") > vote['date_end'] and not vote['is_terminated']:
         flash(u'La deadline du vote est expirée, vous devriez terminer le vote.')
         flash(u'La deadline du vote est expirée, vous devriez terminer le vote.')
     return render_template('admin_vote_edit.html', vote=vote, group=group, values_=values_, choices=choices, attachments=attachments, quorums=QUORUMS)
     return render_template('admin_vote_edit.html', vote=vote, group=group, values_=values_, choices=choices, attachments=attachments, quorums=QUORUMS)
 
 

+ 1 - 0
templates/admin_vote_edit.html

@@ -140,6 +140,7 @@
                 {% else %}
                 {% else %}
                   <option selected>Fermé</option>
                   <option selected>Fermé</option>
                   <option>Ouvert</option>
                   <option>Ouvert</option>
+                  <option>Terminé</option>
                 {% endif %}
                 {% endif %}
             {% endif %}
             {% endif %}
           </select>
           </select>