import hashlib
import smtplib
import string
+import re
+from collections import OrderedDict
from settings import *
else:
return user.get('id')
+#@oid.loginhandler
@app.route('/login', methods=['GET', 'POST'])
-@oid.loginhandler
def login():
if request.method == 'POST':
user = valid_login(request.form['username'], request.form['password'])
return redirect(url_for('home'))
return render_template('login.html')
-@oid.after_login
+#@oid.after_login
def create_or_login(resp):
openid_url = resp.identity_url
user = query_db('select * from users where openid = ?', [openid_url], one=True)
users[t['userid']]['username'] = t['username']
users[t['userid']]['is_admin'] = t['is_admin']
users[t['userid']]['groups'] = [t['groupname']]
-
return render_template('admin_users.html', users=users.values())
@app.route('/admin/users/add', methods=['GET', 'POST'])
if request.form['username']:
if query_db('select * from users where name=?', [request.form['username']], one=True) is None:
admin = 0
- if 'admin' in request.form.keys():
+ if 'admin' in request.form:
admin = 1
key = 'v%s' % keygen()
g.db.execute('insert into users (email, openid, name, organization, password, is_admin, key) \
if query_db('select * from users where email=? and id!=?', [request.form['email'], iduser], one=True) is None:
if query_db('select * from users where name=? and id!=?', [request.form['name'], iduser], one=True) is None:
admin = 0
- if 'admin' in request.form.keys():
+ if 'admin' in request.form:
admin = 1
g.db.execute('update users set email = ?, name = ?, organization = ?, openid= ?, is_admin = ? where id = ?',
[request.form['email'], request.form['name'], request.form['organization'], request.form['openid'], admin, iduser])
left join (' + max_votes + ') as max_votes on votes.id_group = max_votes.id_group'
nb_votes = 'select id_vote, count(*) as nb_votes \
from (select id_user, id_vote \
- from user_choice \
- join choices on id_choice = choices.id \
+ from user_vote \
group by id_user, id_vote) \
group by id_vote'
basequery = 'select * from (' + basequery + ') \
basequery = 'select votes.* from user_group \
join (' + basequery + ') as votes on votes.id_group = user_group.id_group \
where user_group.id_user = ?'
- already_voted = 'select id_vote from user_choice \
- join choices on user_choice.id_choice = choices.id \
+ already_voted = 'select id_vote from user_vote \
where id_user = ?'
votes = query_db(basequery + ' and votes.id not in (' + already_voted + ') and is_terminated=0', [get_userid(), get_userid()])
else:
return False
def has_voted(idvote, iduser=-1):
- vote = query_db('select * from user_choice \
- join choices on id_choice=choices.id \
+ vote = query_db('select * from user_vote \
where id_vote = ? and id_user = ?', [idvote, iduser], one=True)
return (vote is not None)
abort(404)
if can_see_vote(idvote, get_userid()):
choices = query_db('select name, id from choices where id_vote=?', [idvote])
+ values = query_db('select weight,name from values_ where id_cardinal=? order by weight ASC', [vote['id_cardinal']])
+ values.insert(0, {'weight':None,'name':u'=X̄ (Pas d’Opinion)'})
+ for v in values:
+ v['class'] = "value_" + re.sub('[^a-zA-Z0-9-]', '_', v['name'])
+ weights = OrderedDict([(v['weight'], v) for v in values])
if request.method == 'POST':
if can_vote(idvote, get_userid()):
- if vote['is_multiplechoice'] == 0:
- choice = request.form['choice']
- if choice in [str(c['id']) for c in choices] \
- and query_db('select * from choices where id = ?', [choice], one=True) is not None:
- g.db.execute('insert into user_choice (id_user, id_choice) values (?, ?)',
- [session.get('user').get('id'), request.form['choice']])
- g.db.commit()
- else:
- for choice in choices:
- if str(choice['id']) in request.form.keys():
- g.db.execute('insert into user_choice (id_user, id_choice) values (?, ?)',
- [session.get('user').get('id'), choice['id']])
- g.db.commit()
+ userid = session.get('user').get('id') if not vote['is_anonymous'] else None
+ # ACTION: store user's choices
+ for choice in choices:
+ if choice['name'] is None:
+ continue
+ weight = request.form.get('value-'+str(choice['id']),None)
+ if weight is not None and len(weight) is 0:
+ weight = None
+ if weight is not None:
+ weight = int(weight)
+ g.db.execute('insert into user_choice (id_user, id_choice, id_cardinal, weight) \
+ values (?, ?, ?, ?)', [userid, choice['id'], vote['id_cardinal'], weight])
+ g.db.commit()
+ # ACTION: randomize storage when anonymous votes
+ if vote['is_anonymous']:
+ g.db.execute('delete from user_choice_buffer_anonymous')
+ g.db.execute('insert into user_choice_buffer_anonymous select * \
+ from user_choice where id_choice in (%s)'
+ % ','.join(['?'] * len(choices))
+ , tuple(c['id'] for c in choices))
+ g.db.execute('delete from user_choice where id_choice in (%s)'
+ % ','.join(['?'] * len(choices))
+ , tuple(c['id'] for c in choices))
+ g.db.execute('insert into user_choice select * \
+ from user_choice_buffer_anonymous \
+ order by random()')
+ g.db.execute('delete from user_choice_buffer_anonymous')
+ g.db.commit()
+ g.db.execute('insert into user_vote (id_user, id_vote) \
+ values (?, ?)'
+ , [session.get('user').get('id'), vote['id']])
+ g.db.commit()
else:
abort(401)
- tuples = query_db('select choiceid, choicename, users.id as userid, users.name as username \
- from (select choices.id as choiceid, choices.name as choicename, id_user as userid \
- from choices join user_choice on choices.id = user_choice.id_choice \
- where id_vote = ?) \
- join users on userid = users.id', [idvote])
- users = dict()
- for t in tuples:
- if t['userid'] in users:
- users[t['userid']]['choices'].append(t['choiceid'])
- else:
- users[t['userid']] = dict()
- users[t['userid']]['userid'] = t['userid']
- users[t['userid']]['username'] = t['username']
- users[t['userid']]['choices'] = [t['choiceid']]
- choices = query_db('select choices.name, choices.id, choices.name, choices.id_vote, count(id_choice) as nb \
- from choices left join user_choice on id_choice = choices.id where id_vote = ? \
- group by id_choice, name, id_vote order by id', [idvote])
- attachments = query_db('select * from attachments where id_vote=?', [idvote])
- tmp = query_db('select id_group, count(*) as nb from user_group where id_group = ? group by id_group', [vote['id_group']], one=True)
- if tmp is None:
+ # ACTION: count quorum numbers
+ max_votes = query_db('select id_group, count(*) as nb \
+ from user_group where id_group = ? \
+ group by id_group', [vote['id_group']], one=True)
+ if max_votes is None:
vote['percent'] = 0
else:
- vote['max_votes'] = tmp['nb']
- tmp = query_db('select id_vote, count(*) as nb \
- from (select id_user, id_vote from user_choice \
- join choices on id_choice = choices.id \
- group by id_user, id_vote) \
- where id_vote = ? group by id_vote', [idvote], one=True)
- if tmp is None:
+ vote['max_votes'] = max_votes['nb']
+ votes = query_db('select id_vote, count(*) as nb \
+ from (select id_user, id_vote from user_vote \
+ group by id_user, id_vote) \
+ where id_vote = ? group by id_vote', [idvote], one=True)
+ if votes is None:
vote['percent'] = 0
vote['nb_votes'] = 0
else:
- vote['nb_votes'] = tmp['nb']
+ vote['nb_votes'] = votes['nb']
vote['percent'] = int((float(vote['nb_votes']) / float(vote['max_votes'])) * 100)
- if query_db('select * from user_group where id_group = ? and id_user = ?', [vote['id_group'], get_userid()], one=True) and not vote['is_terminated']:
+ # ACTION: query users' choices joined with users' identity if not anonymous
+ user_choices = query_db('select user_choice.id_user as userid, users.name as username, \
+ choices.id as choiceid, choices.name as choice_name, \
+ user_choice.weight as weight \
+ from choices \
+ join user_choice on choices.id = user_choice.id_choice \
+ left join users on userid = users.id \
+ left join user_vote on userid = user_vote.id_user and choices.id_vote = user_vote.id_vote \
+ where choices.id_vote = ? \
+ order by user_vote.date,choices.id', [idvote])
+ # ACTION: aggregate user choices per vote
+ vote['blank'] = 0
+ results = OrderedDict()
+ for c in choices:
+ choice_values = [(w, { 'nb':0
+ , 'idx':i
+ , 'name':weights[w]['name']
+ , 'class':weights[w]['class'] }
+ ) for (i,w) in enumerate(weights, start=0)]
+ choice_values = OrderedDict(choice_values)
+ results[c['id']] = { 'id':c['id']
+ , 'name':c['name']
+ , 'sum':0
+ , 'average':0.0
+ , 'nb':0
+ , 'blank':0
+ , 'values_':choice_values }
+ for uc in user_choices:
+ results[uc['choiceid']]['nb'] += 1
+ results[uc['choiceid']]['values_'][uc['weight']]['nb'] += 1
+ if uc['weight'] is None:
+ results[uc['choiceid']]['blank'] += 1
+ vote['blank'] += 1
+ else:
+ results[uc['choiceid']]['sum'] += uc['weight']
+ for c in results:
+ if results[c]['nb'] - results[c]['blank'] != 0:
+ results[c]['average'] = results[c]['average'] + (float(results[c]['sum']) / float(results[c]['nb'] - results[c]['blank']))
+ previous_percent = 0
+ for w in weights:
+ if results[c]['nb'] > 0:
+ percent = float(results[c]['values_'][w]['nb'] * 100) / results[c]['nb']
+ else:
+ percent = 0.
+ results[c]['values_'][w]['percent'] = percent
+ results[c]['values_'][w]['previous_percent'] = previous_percent
+ previous_percent += percent
+ results[c]['values_'] = results[c]['values_'].values()
+ results = sorted(results.values(), key=lambda c: c['average'], reverse=True)
+ len_results = len(results)
+ if len_results % 2 == 0:
+ medians = results[len_results/2-1:len_results/2+1]
+ else:
+ medians = [results[len_results/2]]
+ results = { 'list':results
+ , 'medians':[m['id'] for m in medians]
+ , 'average':sum([r['sum'] for r in results])/len_results }
+ # ACTION: list user results per user
+ users = OrderedDict()
+ if vote['is_anonymous']:
+ user_votes = query_db('select users.name, id_user as userid \
+ from user_vote \
+ join users on users.id = id_user where id_vote = ?', [idvote])
+ for uc in user_votes:
+ users[uc['userid']] = { 'username':uc['name']
+ , 'choices':{}
+ , 'userid':uc['userid'] }
+ else:
+ for uc in user_choices:
+ weight = uc['weight']
+ value = { 'weight':weight
+ , 'name':weights[weight]['name']
+ , 'class':weights[weight]['class'] }
+ if uc['userid'] in users:
+ users[uc['userid']]['choices'][uc['choiceid']] = value
+ else:
+ users[uc['userid']] = { 'userid':uc['userid']
+ , 'username':uc['username']
+ , 'choices':{uc['choiceid']:value} }
+ attachments = query_db('select * from attachments where id_vote=?', [idvote])
+ if query_db('select * from user_group where id_group = ? and id_user = ?'
+ , [vote['id_group'], get_userid()], one=True) and not vote['is_terminated']:
flash(u'Ce vote vous concerne !', 'info')
- return render_template('vote.html', vote=vote, attachments=attachments, choices=choices, users=users.values(), can_vote=can_vote(idvote, get_userid()))
+ return render_template('vote.html', vote=vote, attachments=attachments
+ , values=values, choices=choices, results=results, users=users.values()
+ , can_vote=can_vote(idvote, get_userid()))
flash(u'Vous n\'avez pas le droit de voir ce vote, désolé.')
return redirect(url_for('home'))
def vote_deletechoices(idvote, iduser):
if int(iduser) != get_userid():
abort(401)
- g.db.execute('delete from user_choice where id_user = ? and id_choice in (select id from choices where id_vote = ?)',
- [iduser, idvote])
- g.db.commit()
+ vote = query_db('select votes.* from votes \
+ where votes.id=?', [idvote], one=True)
+ if not vote['is_terminated'] and not vote['is_anonymous']:
+ g.db.execute('delete from user_choice where id_user = ? and id_choice \
+ in (select id from choices where id_vote = ?)'
+ , [iduser, idvote])
+ g.db.commit()
+ g.db.execute('delete from user_vote where id_user = ? and id_vote \
+ in (select id_vote from choices where id_vote = ?)'
+ , [iduser, idvote])
+ g.db.commit()
return redirect(url_for('vote', idvote=idvote))
#-------------
def admin_vote_add():
if not session.get('user').get('is_admin'):
abort(401)
+ cardinals= OrderedDict([(len(values), {'name':name,'values':values,'first':first}) for (name, first, values) in CARDINALS])
if request.method == 'POST':
if request.form['title']:
if query_db('select * from votes where title = ?', [request.form['title']], one=True) is None:
date_end = date.today() + timedelta(days=int(request.form['days']))
transparent = 0
public = 0
- multiplechoice = 0
- if 'transparent' in request.form.keys():
+ anonymous = 0
+ if 'transparent' in request.form:
transparent = 1
- if 'public' in request.form.keys():
+ if 'public' in request.form:
public = 1
- if 'multiplechoice' in request.form.keys():
- multiplechoice = 1
+ if 'anonymous' in request.form:
+ anonymous = 1
+ try: quorum = float(request.form.get('quorum'))
+ except ValueError:
+ quorum = 0
+ if not (0 <= quorum and quorum <= 1):
+ flash(u'Une erreur est survenue !', 'error')
group = query_db('select id from groups where name = ?', [request.form['group']], one=True)
if group is None:
group[id] = 1
+ try: cardinal = int(request.form.get('cardinal'))
+ except ValueError:
+ cardinal = None
+ if cardinal in cardinals:
+ cardinal_name = cardinals[cardinal]['name']
+ cardinal_values = cardinals[cardinal]['values']
+ weight = cardinals[cardinal]['first'] if not cardinals[cardinal]['first'] is None else -(cardinal/2)
+ if query_db('select * from cardinals where id = ?', [cardinal], one=True) is None:
+ g.db.execute('insert into cardinals (id, name) values (?, ?)', [len(cardinal_values), cardinal_name])
+ g.db.commit()
+ for name in cardinal_values:
+ g.db.execute('insert into values_ (id_cardinal, name, weight) values (?, ?, ?)'
+ , [cardinal, name, weight])
+ g.db.commit()
+ weight += 1
g.db.execute('insert into votes (title, description, category, \
- date_begin, date_end, is_transparent, is_public, is_multiplechoice, id_group, id_author) \
- values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
+ date_begin, date_end, quorum, is_transparent, is_public, \
+ is_anonymous, id_group, id_author, id_cardinal) \
+ values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[ request.form['title'], request.form['description'], request.form['category']
- , date_begin, date_end, transparent, public, multiplechoice, group['id'], session['user']['id'] ])
+ , date_begin, date_end, quorum, transparent, public, anonymous
+ , group['id'], session['user']['id'], cardinal ])
g.db.commit()
- vote = query_db('select * from votes where title = ? and date_begin = ? order by id desc',
- [request.form['title'], date_begin], one=True)
+ vote = query_db('select * from votes where title = ? and date_begin = ? order by id desc'
+ , [request.form['title'], date_begin], one=True)
if vote is None:
flash(u'Une erreur est survenue !', 'error')
return redirect(url_for('home'))
else:
- if request.form['pattern'] in PATTERNS.keys():
+ if request.form['pattern'] in PATTERNS:
pattern = PATTERNS[request.form['pattern']]
for choice in pattern:
g.db.execute('insert into choices (name, id_vote) values (?, ?)', [choice, vote['id']])
flash(u'Le titre que vous avez choisi est déjà pris.', 'error')
else:
flash(u'Vous devez spécifier un titre.', 'error')
- groups = query_db('select * from groups')
- return render_template('admin_vote_new.html', groups=groups, patterns=PATTERNS)
+ groups = query_db('select * from groups')
+ return render_template('admin_vote_new.html', groups=groups, cardinals=cardinals
+ , quorums=QUORUMS, patterns=PATTERNS)
@app.route('/admin/votes/edit/<voteid>', methods=['GET', 'POST'])
def admin_vote_edit(voteid):
date_end = date_end.strftime("%Y-%m-%d")
transparent = 0
public = 0
- if 'transparent' in request.form.keys():
+ if 'transparent' in request.form:
transparent = 1
- if 'public' in request.form.keys():
+ if 'public' in request.form:
public = 1
isopen = 0
isterminated = 0
if request.form['status'] == 'Ouvert':
- choices = query_db('select id_vote, count(*) as nb from choices where id_vote = ? group by id_vote', [voteid], one=True)
- if choices is not None and choices['nb'] >= 2:
+ choices = query_db('select id_vote, count(*) as nb \
+ from choices where id_vote = ? \
+ group by id_vote', [voteid], one=True)
+ if choices is not None and choices['nb'] >= 1:
isopen = 1
previousvote = query_db('select id, is_open, id_group from votes where id = ?', [voteid], one=True)
if previousvote is None or previousvote['is_open'] == 0:
server.sendmail(EMAIL, [user['email']], BODY.encode('utf-8'))
server.quit()
else:
- flash(u'Vous devez proposer au moins deux choix pour ouvrir le vote.', 'error')
+ flash(u'Vous devez proposer au moins un choix pour ouvrir le vote.', 'error')
elif request.form['status'] == u'Terminé':
isterminated = 1
if vote['is_open']:
isopen = 1
- g.db.execute('update votes set title = ?, description = ?, category = ?, \
+ g.db.execute('update votes set title = ?, description = ?, category = ?, quorum = ?, \
is_transparent = ?, is_public = ?, is_open = ?, is_terminated = ?, \
date_end = ?, reminder_last_days = ? where id = ?',
- [ request.form['title'], request.form['description'], request.form['category']
+ [ request.form['title'], request.form['description'], request.form['category'], request.form['quorum']
, transparent, public, isopen, isterminated, date_end, request.form['reminder'], voteid ])
g.db.commit()
vote = query_db('select * from votes where id = ?', [voteid], one=True)
vote['duration'] = (datetime.strptime(vote['date_end'], "%Y-%m-%d") - datetime.strptime(vote['date_begin'], "%Y-%m-%d")).days
group = query_db('select name from groups where id = ?', [vote['id_group']], one=True)
choices = query_db('select * from choices where id_vote = ?', [voteid])
+ values_ = query_db('select * from cardinals where id = ?', [vote['id_cardinal']], one=True)['name']
attachments = query_db('select * from attachments where id_vote = ?', [voteid])
if date.today().strftime("%Y-%m-%d") > vote['date_end']:
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, choices=choices, attachments=attachments)
+ return render_template('admin_vote_edit.html', vote=vote, group=group, values_=values_, choices=choices, attachments=attachments, quorums=QUORUMS)
@app.route('/admin/votes/delete/<idvote>')
def admin_vote_del(idvote):
abort(404)
g.db.execute('delete from choices where id = ? and id_vote = ?', [choiceid, voteid])
g.db.commit()
- choices = query_db('select id_vote, count(*) as nb from choices where id_vote = ? group by id_vote', [voteid], one=True)
+ choices = query_db('select id_vote, count(*) as nb \
+ from choices where id_vote = ? \
+ group by id_vote', [voteid], one=True)
if choices is None or choices['nb'] < 2:
g.db.execute('update votes set is_open=0 where id = ?', [voteid])
g.db.commit()
drop table if exists user_choice;
+drop table if exists user_choice_buffer_anonymous;
+drop table if exists user_vote;
drop table if exists choices;
+drop table if exists cardinals;
+drop table if exists values_;
drop table if exists attachments;
drop table if exists votes;
drop table if exists user_group;
PRIMARY KEY(id_user, id_group)
);
+create table cardinals (
+ id INTEGER UNIQUE NOT NULL PRIMARY KEY,
+ name TEXT UNIQUE NOT NULL,
+ first INTEGER NOT NULL
+);
+
+create table values_ (
+ name TEXT NOT NULL,
+ weight INTEGER NOT NULL,
+ id_cardinal INTEGER NOT NULL,
+ FOREIGN KEY(id_cardinal) REFERENCES cardinals (id) ON DELETE CASCADE,
+ PRIMARY KEY(id_cardinal, weight)
+);
+
create table votes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
category TEXT,
date_begin INTEGER DEFAULT CURRENT_TIMESTAMP NOT NULL,
date_end INTEGER NOT NULL,
- is_transparent BOOLEAN DEFAULT 1 NOT NULL,
+ quorum FLOAT DEFAULT 1,
+ reminder_last_days INTEGER DEFAULT 3 NOT NULL,
+ is_transparent BOOLEAN DEFAULT 1 NOT NULL,
is_public BOOLEAN DEFAULT 1 NOT NULL,
- is_multiplechoice BOOLEAN DEFAULT 1 NOT NULL,
- is_weighted BOOLEAN DEFAULT 0 NOT NULL,
+ is_anonymous BOOLEAN DEFAULT 1 NOT NULL,
is_open BOOLEAN DEFAULT 0 NOT NULL,
is_terminated BOOLEAN DEFAULT 0 NOT NULL,
+ is_hidden BOOLEAN DEFAULT 0 NOT NULL,
id_author INTEGER DEFAULT 1 NOT NULL,
id_group INTEGER DEFAULT 1 NOT NULL,
+ id_cardinal INTEGER NOT NULL,
FOREIGN KEY(id_author) REFERENCES users (id) ON DELETE SET DEFAULT,
FOREIGN KEY(id_group) REFERENCES groups (id),
+ FOREIGN KEY(id_cardinal) REFERENCES cardinals (id),
CHECK (is_transparent IN (0, 1)),
CHECK (is_public IN (0, 1)),
- CHECK (is_weighted IN (0, 1)),
CHECK (is_open IN (0, 1)),
- CHECK (is_terminated IN (0, 1))
+ CHECK (is_terminated IN (0, 1)),
+ CHECK (is_hidden IN (0, 1))
);
create table attachments (
create table user_choice (
id_user INTEGER,
- id_choice INTEGER,
+ id_choice INTEGER NOT NULL,
+ id_cardinal INTEGER,
weight INTEGER,
FOREIGN KEY(id_user) REFERENCES users (id) ON DELETE CASCADE,
FOREIGN KEY(id_choice) REFERENCES choices (id) ON DELETE CASCADE,
+ FOREIGN KEY(id_cardinal, weight) REFERENCES values_ (id_cardinal, weight) ON DELETE CASCADE,
PRIMARY KEY(id_user, id_choice)
);
+create table user_choice_buffer_anonymous (
+ -- NOTE: same table structure as user_choice, used to randomize insertion per vote
+ id_user INTEGER,
+ id_choice INTEGER NOT NULL,
+ id_cardinal INTEGER,
+ weight INTEGER,
+ FOREIGN KEY(id_user) REFERENCES users (id) ON DELETE CASCADE,
+ FOREIGN KEY(id_choice) REFERENCES choices (id) ON DELETE CASCADE,
+ FOREIGN KEY(id_cardinal, weight) REFERENCES values_ (id_cardinal, weight) ON DELETE CASCADE,
+ PRIMARY KEY(id_user, id_choice)
+);
+
+create table user_vote (
+ date INTEGER DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ id_user INTEGER NOT NULL,
+ id_vote INTEGER NOT NULL,
+ FOREIGN KEY(id_user) REFERENCES users (id) ON DELETE CASCADE,
+ FOREIGN KEY(id_vote) REFERENCES votes (id) ON DELETE CASCADE,
+ PRIMARY KEY(id_user, id_vote)
+);
+
-- Test data
INSERT INTO users (id, email, password, openid, name, organization, is_admin, key)
-VALUES (1, "admin@admin.fr", "", "", "Toto (admin) Tata", "World corp", 1, "victory");
+VALUES (1, "admin+cavote+1@localhost.localdomain", "", "", "admin1", "Organisation", 1, "victory");
+INSERT INTO users (id, email, password, openid, name, organization, is_admin, key)
+VALUES (2, "admin+cavote+2@localhost.localdomain", "", "", "admin2", "Organisation", 1, "victory");
+INSERT INTO users (id, email, password, openid, name, organization, is_admin, key)
+VALUES (3, "admin+cavote+3@localhost.localdomain", "", "", "admin3", "Organisation", 1, "victory");
+INSERT INTO users (id, email, password, openid, name, organization, is_admin, key)
+VALUES (4, "admin+cavote+4@localhost.localdomain", "", "", "admin4", "Organisation", 1, "victory");
+INSERT INTO users (id, email, password, openid, name, organization, is_admin, key)
+VALUES (4, "admin+cavote+5@localhost.localdomain", "", "", "admin5", "Organisation", 1, "victory");
-- to login, go to /login/1/victory
-INSERT INTO groups (id, name, system) VALUES (1, "Tous", 1);
+INSERT INTO groups (id, name, system) VALUES (1, "Tout le monde", 1);
INSERT INTO groups (name) VALUES ("CA");
INSERT INTO groups (name) VALUES ("Membres");
INSERT INTO user_group (id_user, id_group) VALUES(1, 1);
+INSERT INTO user_group (id_user, id_group) VALUES(2, 1);
+INSERT INTO user_group (id_user, id_group) VALUES(3, 1);
+INSERT INTO user_group (id_user, id_group) VALUES(4, 1);
+INSERT INTO user_group (id_user, id_group) VALUES(5, 1);
+++ /dev/null
-ALTER TABLE votes
-ADD is_hidden BOOLEAN DEFAULT 0 NOT NULL;
+++ /dev/null
-ALTER TABLE votes
-ADD reminder_last_days INTEGER DEFAULT 3 NOT NULL;
PASSWD_SALT = 'change this value to some random chars!'
SECRET_KEY = '{J@uRKO,xO-PK7B,jF?>iHbxLasF9s#zjOoy=+:'
DEBUG = True
-TITLE = u"Cavote FFDN"
-EMAIL = '"' + TITLE + '"' + ' <' + u"cavote@ffdn.org" + '>'
-VERSION = "cavote 0.3.0"
+TITLE = u"Cavote"
+EMAIL = '"' + TITLE + '"' + ' <' + u"contact+cavote@localhost.localdomain" + '>'
+VERSION = "cavote 0.4.0"
SMTP_SERVER = "127.0.0.1"
-PATTERNS = {u'Oui/Non': [u'Oui', u'Non'], u'Oui/Non/Blanc': [u'Oui', u'Non', u'Blanc'], u'Oui/Non/Peut-être': [u'Oui', u'Non', u'Peut-être']}
+PATTERNS = \
+ { u'Oui/Non': [u'Oui', u'Non'] \
+ }
+CARDINALS = \
+ [ (u'Sans moi/Avec moi'
+ , 0, [u'±0 (Sans moi)', u'+1 (Avec moi)']) \
+ , (u'Hostile/Indifférent/Favorable'
+ , -1, [u'-1 (Hostile)', u'±0 (Indifférent)', u'+1 (Favorable)']) \
+ , (u'Très Hostile/Hostile/Indifférent/Favorable/Très Favorable'
+ , -2, [u'-2 (Très Hostile)', u'-1 (Hostile)', u'±0 (Indifférent)', u'+1 (Favorable)', u'+2 (Très Favorable)']) \
+ ]
+QUORUMS = \
+ [ 0
+ , 0.1
+ , 0.25
+ , 0.333
+ , 0.5
+ , 0.666
+ , 0.75
+ , 0.9
+ , 1
+ ]
BABEL_DEFAULT_LOCALE = 'fr'
BABEL_DEFAULT_TIMEZONE = 'Europe/Paris'
+VOTE_URL = "http://localhost:5000/vote/%d"
-.table-votes th {
+.page-header {
+ padding-bottom:0;
+ margin-top:9px;
+ }
+
+.table-votes thead th {
text-align: right;
+ vertical-align: middle;
+}
+.table-votes th.choice-name {
+ text-align: center;
}
.table-votes input {
margin: 0;
}
+.row {
+ margin-left:0;
+ }
+
.table-votes td {
text-align: center;
+ vertical-align: middle;
}
.table-votes .yes {
.table-votes tr:hover .no {
background-color: #C73F38; /* red */
}
+
+.table-votes input,
+.table-votes textarea,
+.table-votes select,
+.table-votes .uneditable-input {
+ width:auto;
+ margin-bottom:0;
+ }
+
+.table-votes td {
+ font-family:sans-serif;
+ font-size:12px;
+ }
+.table-votes .value_black {
+ background-color:black !important;
+ }
+.value__X___Pas_d_Opinion_ {
+ background-color:white !important;
+ color:black !important;
+ text-shadow: 0 0 2px #ccc !important;
+ fill:white;
+ }
+.results .value__X___Pas_d_Opinion_ + text {
+ fill:black;
+ }
+.table-votes *[class^="value_"] {
+ color:white;
+ text-shadow: 0 0 2px #000;
+ }
+.cardinal-2 .value__0__Sans_moi_ {
+ background-color:#B4B4B4 !important;
+ fill:#B4B4B4;
+ }
+.cardinal-2 .value__1__Avec_moi_ {
+ background-color:#20B756 !important;
+ fill:#20B756;
+ }
+.cardinal-2 .value__1__Favorable_ {
+ background-color:#20B756 !important;
+ fill:#20B756;
+ }
+.cardinal-3 .value_-1__Hostile_ {
+ background-color:#DB4343 !important;
+ fill:#DB4343;
+ }
+.cardinal-3 .value__0__Indiff_rent_ {
+ background-color:#B4B4B4 !important;
+ fill:#B4B4B4;
+ }
+.cardinal-3 .value__1__Favorable_ {
+ background-color:#20B756 !important;
+ fill:#20B756;
+ }
+.cardinal-5 .value_-2__Tr_s_Hostile_ {
+ background-color:#DB4343 !important;
+ fill:#DB4343;
+ }
+.cardinal-5 .value_-1__Hostile_ {
+ background-color:#E49F37 !important;
+ fill:#E49F37;
+ }
+.cardinal-5 .value__0__Indiff_rent_ {
+ background-color:#B4B4B4 !important;
+ fill:#B4B4B4;
+ }
+.cardinal-5 .value__1__Favorable_ {
+ background-color:#B1D039 !important;
+ fill:#B1D039;
+ }
+.cardinal-5 .value__2__Tr_s_Favorable_ {
+ background-color:#20B756 !important;
+ fill:#20B756;
+ }
+.container,
+.navbar-fixed-top .container,
+.navbar-fixed-bottom .container {
+ width:auto;
+ }
+.span3 {
+ width:24em;
+ }
+.span8 {
+ width:625px;
+ }
+.span8 svg {
+ margin:0;
+ padding:0;
+ }
+
+.results rect {
+ //fill: steelblue;
+ }
+.results g.value_-2 rect {
+ fill: #DB4343;
+ }
+.results g.value_-1 rect {
+ fill: #E49F37;
+ }
+.results g.value__0 rect {
+ fill: #B4B4B4;
+ }
+.results g.value__1 rect {
+ fill: #B1D039;
+ }
+.results g.value__2 rect {
+ fill: #20B756;
+ }
+.results text.choice {
+ fill: black;
+ }
+.results text.choice-legend {
+ fill: black;
+ font-weight:bold;
+ }
+.results text.choice-legend-item {
+ fill: black;
+ }
+.results text.choice-sum {
+ fill: black;
+ font-weight:bold;
+ }
+.results text.choice-average {
+ fill: black;
+ font-weight:bold;
+ }
+.results text.choice-sum-legend {
+ fill: blue;
+ font-weight:bold;
+ }
+.results text.choice-average-legend {
+ fill: blue;
+ font-weight:bold;
+ }
+.results text.choice-median {
+ fill: blue;
+ font-weight:bold;
+ }
+.results text {
+ fill: white;
+ font: 10px sans-serif;
+ text-anchor: end;
+ }
+
+.results .axis text {
+ fill: black;
+ font: 10px sans-serif;
+ }
+.results .axis path,
+.results .axis line {
+ fill: none;
+ shape-rendering: crispEdges;
+ stroke: #000;
+ }
<input type="text" data-provide="typeahead" data-source='["ca","membres"]' size=30 name="category" id="category" value="{{ vote.category }}" />
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="category">Quorum</label>
+ <div class="controls">
+ <select name="quorum" id="quorum">
+ {% for quorum in quorums %}
+ {% if quorum == vote.quorum %}
+ <option value="{{ quorum }}" selected>{{ quorum * 100 }}%</option>
+ {% else %}
+ <option value="{{ quorum }}">{{ quorum * 100 }}%</option>
+ {% endif %}
+ {% endfor %}
+ </select>
+ </div>
+ </div>
<div class="control-group">
<label class="control-label" for="role">Groupe</label>
<div class="controls">
</label>
{% if not vote.is_terminated == 1 %}
<label class="checkbox">
- <input type="checkbox" name="multiplechoice" {% if vote.is_multiplechoice == 1 %} checked {% endif %} disabled/>
- Les votants peuvent-ils choisir plusieurs options ?
+ <input type="checkbox" name="anonymous" {% if vote.is_anonymous == 1 %} checked {% endif %} disabled/>
+ Les votes sont-ils anonymes ?
</label>
{% endif %}
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="value">Valeurs</label>
+ <div class="controls">
+ <select name="value" id="value" disabled>
+ <option>{{ values_ }}</option>
+ </select>
+ </div>
+ </div>
</div>
</div>
</div>
<input type="text" data-provide="typeahead" data-source='["ca","membres"]' size=30 name="category" id="category" value="{{ request.form.category }}" />
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="quorum">Quorum</label>
+ <div class="controls">
+ <select name="quorum" id="quorum">
+ {% for quorum in quorums %}
+ <option value="{{ quorum }}">{{ quorum * 100 }}%</option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
<div class="control-group">
<label class="control-label" for="group">Groupe</label>
<div class="controls">
Le vote est-il visible par tous ?
</label>
<label class="checkbox">
- <input type="checkbox" name="multiplechoice" />
- Les votants peuvent-ils choisir plusieurs options ?
+ <input type="checkbox" name="anonymous" />
+ Les votes sont-ils anonymes ?
</label>
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="cardinal">Valeurs</label>
+ <div class="controls">
+ <select name="cardinal" id="cardinal">
+ {% for cardinal in cardinals %}
+ <option value="{{ cardinal }}">{{ cardinals[cardinal].name }}</option>
+ {% endfor %}
+ </select>
+ </div>
+ </div>
<div class="control-group">
<label class="control-label" for="pattern">Schéma</label>
<div class="controls">
<td>{{ vote.category }}</td>
<td>
{% if vote.is_transparent %}<span class="label">transparent</span>{% endif %}
+ {% if vote.is_anonymous %}<span class="label">anonymous</span>{% endif %}
{% if vote.is_public %}<span class="label">public</span>{% endif %}
- {% if vote.is_multiplechoice %}<span class="label">multiple</span>{% endif %}
</td>
<td>
<a href="{{ url_for('vote', idvote=vote.voteid) }}" class="btn btn-success btn-mini">Voir</a>
<p>
<strong>Légende :</strong>
<ul class="unstyled">
- <li><span class="label">transparent</span> : Les utilisateurs peuvent voir les votes des autres</li>
+ <li><span class="label">transparent</span> : Les votants peuvent voir les votes des autres</li>
+ <li><span class="label">anonymous</span> : Les suffrages du vote sont déliés de l’identité de leur votant</li>
<li><span class="label">public</span> : Tout le monde peut voir le vote</li>
- <li><span class="label">multiple</span> : Les utilisateurs peuvent effectuer plusieurs choix</li>
</ul>
</p>
{% endif %}
{% extends "layout.html" %}
{% block body %}
{% if error %}<p class=error><strong>Error:</strong> {{ error }}{% endif %}
- <p>Bienvenue sur cavote, l'outil de vote de la Fédération FDN !</p>
+ <p>Bienvenue sur Cavote, un outil de vote convivial</p>
{% endblock %}
</div>
</header>
-<h1 class="page-header">Outil de vote du CA FFDN <small>{% block subtitle %}{% endblock %}</small></h1>
+<h1 class="page-header">{% block subtitle %}{% endblock %}</h1>
{% with messages = get_flashed_messages(with_categories="true") %}
{% if messages %}
{% for category, message in messages %}
{% extends "layout.html" %}
+{% block subtitle %}{{vote.title}}{% endblock %}
{% block body %}
<div class="row">
+<div class="span3">
+<h2 class="page-header">Informations</h2>
+<div class="progress progress-striped progress-{% if vote.nb_votes > 0 and vote.nb_votes / vote.max_votes >= vote.quorum %}success{% else %}danger{% endif %}">
+ <div class="bar" style="width: {{ vote.percent }}%;">
+ <strong>{{ vote.nb_votes }} vote{{ 's' if vote.nb_votes > 1 else '' }} / {{ vote.max_votes }} ({{ vote.percent }}%)</strong></div>
+</div>
+<dl class="dl-horizontal">
+ <dt>Publié par <dd><code>{{ vote.author }}</code>
+ <dt>Début le <dd><code>{{ vote.date_begin }}</code>
+ <dt>Fin le <dd><code>{{ vote.date_end }}</code>
+ <dt>Groupe <dd><code>{{ vote.groupname }}</code>
+ <dt>Catégorie <dd><code>{{ vote.category }}</code>
+ <dt>Quorum <dd><code>{{ vote.quorum * 100 }}%</code>
+</dl>
+<dl>
+ {% if vote.description %}
+ <dt>Description : <dd>{{ vote.description }}
+ {% endif %}
+ {% if attachments %}
+ <dt>Documents :<dd>
+ <ul>
+ {% for attachment in attachments %}
+ <li><a href="{{ attachment.url }}">{{ attachment.url }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+</dl>
+</div>
+
+{% if vote.is_transparent or (session.user and user.userid == session.user.id )%}
+<div class="span8">
+ <h2 class='page-header'>Résultats</h2>
+ <svg class="results cardinal-{{ vote.id_cardinal }}"
+ width="{{ 150 + (100 * 5) + 50 + 100 + 100 }}"
+ height="{{25 + results.list|length * 20 + 40}}">
+ <g class="choice" transform="translate(100,0)">
+ <text class="choice-legend" x="-10" y="9.5" dy=".35em">Légende :</text>
+ </g>
+ {% for value in values %}
+ <g transform="translate({{ 150 + (loop.index0 * 640 / loop.length) }},0)">
+ <rect width="{{ 640 / loop.length }}" height="20"></rect>
+ <rect class="{{ value.class }}" x="1" y ="1" width="{{ 640 / loop.length - 1}}" height="19"></rect>
+ <text class="choice-legend-item" text-anchor="start" x="{{ 640 / loop.length - 2 }}" y="9.5" dy=".35em"
+ >{{ value.name }}</text>
+ </g>
+ {% endfor %}
+ <g transform="translate({{150 + (100 * 5) + 35}},20)">
+ <text class="choice-sum-legend" x="20" y="9.5" dy=".35em">somme↓</text>
+ </g>
+ <g transform="translate({{150 + (100 * 5) + 115}},20)">
+ <text class="choice-average-legend" x="20" y="9.5" dy=".35em">moyenne↓</text>
+ </g>
+ {% for choice in results.list %}
+ <g class="choice" transform="translate(150,{{ 35 + loop.index0 * 20 }})">
+ <text class="choice" x="-10" y="9.5" dy=".35em">{{ choice.name }}</text>
+ </g>
+ {% set choice_loop = loop %}
+ {% for value in choice.values_ %}
+ <g transform="translate({{ 150 + (value.previous_percent * 5) }},{{ 35 + choice_loop.index0 * 20 }})">
+ {% if value.percent > 0 %}
+ <rect class="{{ value.class }}" width="{{ (value.percent * 5)|int }}" height="19"></rect>
+ <text text-anchor="middle" x="{{ (value.percent * 5 / 2 + 10)|int }}" y="9.5" dy=".35em"
+ >{{ value.percent|int }}%</text>
+ {% endif %}
+ </g>
+ {% endfor %}
+ <g transform="translate({{150 + (100 * 5) + 35}},{{35 + loop.index0 * 20}})">
+ <text class="choice-sum" x="20" y="9.5" dy=".35em">{{ choice.sum }}</text>
+ </g>
+ <g transform="translate({{150 + (100 * 5) + 115}},{{35 + loop.index0 * 20}})">
+ <text class="choice-average" x="20" y="9.5" dy=".35em">{{ "%.2f"|format(choice.average) }}</text>
+ </g>
+ {% if loop.length > 1 and choice.id in results.medians %}
+ <g transform="translate({{150 + (100 * 5) + 125}},{{35 + loop.index0 * 20}})">
+ <text class="choice-median" x="75" y="9.5" dy=".35em">← médiane</text>
+ </g>
+ {%endif%}
+ {% endfor %}
+ <g class="axis" transform="translate(150,{{35 + results.list|length * 20}})">
+ <g transform="translate(0,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">0%</text>
+ </g>
+ <g transform="translate(125,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">25%</text>
+ </g>
+ <g transform="translate(250,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">50%</text>
+ </g>
+ <g transform="translate(375,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">75%</text>
+ </g>
+ <g transform="translate(500,0)" style="opacity: 1;" class="tick">
+ <line x1="0" y1="6" x2="0" y2="0"></line>
+ <text style="text-anchor: middle;" dy=".71em" x="0" y="9">100%</text>
+ </g>
+ <path d="M0,6V0H500V6" class="domain"></path>
+ </g>
+ </svg>
+</div>
+{% endif %}
+
<div class="span9">
- <h2 class='page-header'>{{ vote.title }}</h2>
+ <h2 class='page-header'>Suffrages</h2>
+{% if vote.is_anonymous %}
+<div class="alert alert-info">Ce vote est anonymisé, les suffrages ne sont ni visibles ni modifiables.</div>
+{% endif %}
{% if not vote.is_transparent %}
-<div class="alert alert-info">Ce sondage n'est pas transparent, vous ne pouvez pas voir les votes des autres.</div>
+<div class="alert alert-info">Ce vote n’est pas transparent, vous ne pouvez pas voir les votes des autres.</div>
{% endif %}
-<table class="table table-condensed table-bordered table-votes">
+{% if (vote['is_anonymous'] and can_vote) or not vote['is_anonymous'] %}
+<table class="table table-condensed table-bordered table-votes cardinal-{{ vote.id_cardinal }}">
<thead>
<tr>
<th></th>
{% for choice in choices %}
- <th>{{ choice.name }}</th>
+ <th class="choice-name">{{ choice.name }}</th>
{% endfor %}
- {% if 'user' in session %}
+ {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
<th></th>
{% endif %}
</tr>
+ {% if vote.is_transparent %}
+ <!--
+ <tr>
+ <th>Somme</th>
+ {% for choice in choices %}
+ <td>{{ choice.sum }}</td>
+ {% endfor %}
+ {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
+ <td></td>
+ {% endif %}
+ </tr>
+ -->
+ {% endif %}
+
+ {% if can_vote %}
+ <form class="form-inline" action="{{ url_for('vote', idvote=vote.id) }}" method="post">
+ <tr>
+ <th><input type='text' name="username" value='{{ session.user.name }}' disabled /></th>
+ {% for choice in choices %}
+ <td>
+ <select name="value-{{ choice.id }}" id="value-{{ choice.id }}">
+ {% for value in values %}
+ <option value="{% if value.weight is not none %}{{ value.weight }}{% endif %}" class="{{ value.class }}">{{ value.name }}</option>
+ {% endfor %}
+ </select>
+ </td>
+ {% endfor %}
+ <td><input type="submit" class="btn btn-primary" value="OK" /></td>
+ </tr>
+ </form>
+ {% endif %}
</thead>
+ {% if not vote['is_anonymous'] %}
<tbody>
{% for user in users %}
{% if vote.is_transparent or (session.user and user.userid == session.user.id )%}
<tr>
<th>{% if 'user' in session and user.userid == session.user.id %}<i class="icon-user"></i>{% endif %} {{ user.username }}</th>
{% for choice in choices %}
- {% if choice.id in user.choices %}
- <td class="yes"><i class="icon-ok icon-white"></i></td>
- {% else %}
- <td class="no"></td>{% endif %}
+ <td class="{{user.choices[choice.id].class}}"><span>{{ user.choices[choice.id].name }}</span></td>
{% endfor %}
- {% if 'user' in session %}
+ {% if 'user' in session and (can_vote or (not vote['is_terminated'] and not vote['is_anonymous'])) %}
<td>{% if user.userid == session.user.id %}
<a href="#delete" data-toggle="modal" class="btn btn-danger btn-mini" title="Supprimer"><i class="icon-remove icon-white"></i></a>
<div class="modal hide fade" id="delete">
</tr>
{% endif %}
{% endfor %}
-
- {% if can_vote %}
- <form class="form-inline" action="{{ url_for('vote', idvote=vote.id) }}" method="post">
- <tr>
- <th><input type='text' name="username" value='{{ session.user.name }}' disabled /></th>
- {% if vote.is_multiplechoice %}
- {% for choice in choices %}
- <td><input type='checkbox' name="{{ choice.id }}" value="{{ choice.id }}" /></td>
- {% endfor %}
- {% else %}
- {% for choice in choices %}
- <td><input type='radio' name="choice" value="{{ choice.id }}" /></td>
- {% endfor %}
- {% endif %}
- <td><input type="submit" class="btn btn-primary" value="OK" /></td>
- </tr>
- </form>
- {% endif %}
</tbody>
-
- <tfoot>
- {% if vote.is_transparent %}
- <tr>
- <th>Somme</th>
- {% for choice in choices %}
- <td>{{ choice.nb }}</td>
- {% endfor %}
- {% if 'user' in session %}
- <td></td>
- {% endif %}
- </tr>
{% endif %}
- </tfoot>
</table>
-</div>
-
-<div class="span3">
-<h3>Informations</h3>
-{% if vote.nb_votes == 0 %}
-<div class="progress progress-striped progress-danger">
- <div class="bar" style="width: 100%;"><strong>{{ vote.nb_votes }} / {{ vote.max_votes }}</strong></div>
-</div>
{% else %}
-<div class="progress progress-striped {% if vote.nb_votes == vote.max_votes %}progress-success{% endif %}">
- <div class="bar" style="width: {{ vote.percent }}%;"><strong>{{ vote.nb_votes }} / {{ vote.max_votes }}</strong></div>
-</div>
+{% if not can_vote %}
+<div class="alert alert-info">Vous avez déjà voté.</div>
+{% endif %}
{% endif %}
-<dl class="dl-horizontal">
- <dt>Publié par <dd><code>{{ vote.author }}</code>
- <dt>Début le <dd><code>{{ vote.date_begin }}</code>
- <dt>Deadline le <dd><code>{{ vote.date_end }}</code>
- <dt>Groupe <dd><code>{{ vote.groupname }}</code>
- <dt>Catégorie <dd><code>{{ vote.category }}</code>
-</dl>
-<dl>
- {% if vote.description %}
- <dt>Description : <dd>{{ vote.description }}
- {% endif %}
- {% if attachments %}
- <dt>Documents :<dd>
- <ul>
- {% for attachment in attachments %}
- <li><a href="{{ attachment.url }}">{{ attachment.url }}</a></li>
- {% endfor %}
- </ul>
- {% endif %}
-</dl>
</div>
</div>
<h3><a href="{{ url_for('vote', idvote=vote.voteid) }}">{{ vote.title }}</a></h3>
<div class="row">
<div class="span4">
- {% if vote.nb_votes == 0 %}
- <div class="progress progress-striped progress-danger">
- <div class="bar" style="width: 100%;"><strong>{{ vote.nb_votes }} / {{ vote.max_votes }}</strong></div>
+ <div class="progress progress-striped progress-{% if vote.nb_votes > 0 and vote.nb_votes / vote.max_votes >= vote.quorum %}success{% else %}danger{% endif %}">
+ <div class="bar" style="width: {{ vote.percent }}%;">
+ <strong>{{ vote.nb_votes }} vote{{ 's' if vote.nb_votes > 1 else '' }} / {{ vote.max_votes }} ({{ vote.percent }}%)</strong></div>
</div>
- {% else %}
- <div class="progress progress-striped {% if vote.nb_votes == vote.max_votes %}progress-success{% endif %}">
- <div class="bar" style="width: {{ vote.percent }}%;"><strong>{{ vote.nb_votes }} / {{ vote.max_votes }}</strong></div>
- </div>
- {% endif %}
</div>
</div>
</div>
<div class="span3">
- <h4>Deadline : {{ vote.date_end }} </h4>
+ <h4>Échéance : {{ vote.date_end }} </h4>
<h4>Groupe : {{ vote.groupname }}</h4>
<h4>Categorie : {{ vote.category }}</h4>
</div>