From 251888ac340c188dcf60da3120a752450663d63e Mon Sep 17 00:00:00 2001 From: Guillaume Subiron Date: Tue, 29 May 2012 15:26:28 +0200 Subject: [PATCH] Added metas to vote view, added attachments table --- main.py | 5 +++-- schema.sql | 8 ++++++++ templates/vote.html | 26 ++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index bff42a0..8c050b8 100755 --- a/main.py +++ b/main.py @@ -233,12 +233,13 @@ def can_vote(idvote, iduser=-1): @app.route('/vote/') def show_vote(idvote): - vote = query_db('select * from votes where id=?', [idvote], one=True) + vote = query_db('select *, roles.name as rolename from votes join roles on roles.id=votes.id_role where votes.id=?', [idvote], one=True) if vote is None: abort(404) if can_see_vote(idvote, session.get('user').get('id')): choices = query_db('select * from choices where id_vote=?', [idvote]) - return render_template('vote.html', vote=vote, choices=choices, can_vote=can_vote(idvote, session.get('user').get('id'))) + attachments = query_db('select * from attachments where id_vote=?', [idvote]) + return render_template('vote.html', vote=vote, attachments=attachments, choices=choices, can_vote=can_vote(idvote, session.get('user').get('id'))) flash('Vous n\'avez pas le droit de voir ce vote, désolé.') return(url_for('home')) diff --git a/schema.sql b/schema.sql index f52b8b4..b24a7f3 100644 --- a/schema.sql +++ b/schema.sql @@ -1,4 +1,5 @@ drop table if exists choices; +drop table if exists attachments; drop table if exists votes; drop table if exists roles; drop table if exists users; @@ -37,6 +38,13 @@ create table votes ( FOREIGN KEY(id_role) REFERENCES roles(id) ); +create table attachments ( + url TEXT not null, + id_vote INTEGER not null, + FOREIGN KEY(id_vote) REFERENCES vote(id), + PRIMARY KEY(url, id_vote) +); + create table choices ( id INTEGER primary key autoincrement, name TEXT not null, diff --git a/templates/vote.html b/templates/vote.html index b51896f..3ebec2a 100644 --- a/templates/vote.html +++ b/templates/vote.html @@ -1,8 +1,8 @@ {% extends "layout.html" %} {% block body %} -

{{ vote.title }}

-
+
+ @@ -53,6 +53,28 @@
+ +
+

Informations

+
+
Publié par
maethor +
Début le
{{ vote.date_begin }} +
Fin le
{{ vote.date_end }} +
Groupe
{{ vote.rolename }} +
Catégorie
{{ vote.category }} +
+
+
Description :
{{ vote.description }} +
Documents :
+ + +
+
+
{% endblock %} -- 2.20.1