From: Julien Moutinho Date: Sat, 30 Aug 2014 22:05:31 +0000 (+0200) Subject: fix some little things X-Git-Url: http://git.cyclocoop.org/?p=cavote.git;a=commitdiff_plain;h=afd25590c57cd685b4636a28bac0bf53456ee861 fix some little things --- diff --git a/main.py b/main.py index 8093465..e3f0947 100755 --- a/main.py +++ b/main.py @@ -542,6 +542,7 @@ def vote(idvote): group by id_group', [vote['id_group']], one=True) if max_votes is None: vote['percent'] = 0 + vote['nb_votes'] = 0 else: vote['max_votes'] = max_votes['nb'] votes = query_db('select id_vote, count(*) as nb \ @@ -707,7 +708,7 @@ def admin_vote_add(): 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.execute('insert into cardinals (id, name, first) values (?, ?, ?)', [len(cardinal_values), cardinal_name, weight]) g.db.commit() for name in cardinal_values: g.db.execute('insert into values_ (id_cardinal, name, weight) values (?, ?, ?)' diff --git a/schema.sql b/schema.sql index 7884fe7..67475de 100644 --- a/schema.sql +++ b/schema.sql @@ -42,7 +42,7 @@ create table user_group ( create table cardinals ( id INTEGER UNIQUE NOT NULL PRIMARY KEY, name TEXT UNIQUE NOT NULL, - first INTEGER NOT NULL + first INTEGER ); create table values_ ( @@ -126,25 +126,3 @@ create table user_vote ( 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+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, "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);