@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'))
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;
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,
{% 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 %}