Added metas to vote view, added attachments table
authorGuillaume Subiron <maethor@subiron.org>
Tue, 29 May 2012 13:26:28 +0000 (15:26 +0200)
committerJulien Rabier <taziden@flexiden.org>
Tue, 29 May 2012 17:17:04 +0000 (19:17 +0200)
main.py
schema.sql
templates/vote.html

diff --git a/main.py b/main.py
index bff42a0..8c050b8 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -233,12 +233,13 @@ def can_vote(idvote, iduser=-1):
 
 @app.route('/vote/<idvote>')
 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'))
 
index f52b8b4..b24a7f3 100644 (file)
@@ -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,
index b51896f..3ebec2a 100644 (file)
@@ -1,8 +1,8 @@
 {% extends "layout.html" %}
 {% block body %}
-<h2>{{ vote.title }}</h2>
 <div class="row">
-<div class="span10 offset1">
+<div class="span9">
+<h2 class='page-header'>{{ vote.title }}</h2>
 <table class="table table-condensed table-striped table-bordered">
   <thead>
     <tr>
   </tfoot>
 </table>
 </div>
+
+<div class="span3">
+<h3>Informations</h3>
+<dl class="dl-horizontal">
+  <dt>Publié par <dd><code>maethor</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.rolename }}</code>
+  <dt>Catégorie <dd><code>{{ vote.category }}</code>
+</dl>
+<dl>
+  <dt>Description : <dd>{{ vote.description }}
+  <dt>Documents :<dd>
+  <ul>
+    {% for attachment in attachments %}
+    <li><a href="{{ attachment.url }}">{{ attachment.url }}</a></li>
+    {% endfor %}
+  </ul>
+  </li>
+</dl>
+</div>
+
 </div>
 {% endblock %}