Votes list
authorGuillaume Subiron <maethor@subiron.org>
Tue, 29 May 2012 14:32:53 +0000 (16:32 +0200)
committerJulien Rabier <taziden@flexiden.org>
Tue, 29 May 2012 17:17:12 +0000 (19:17 +0200)
main.py
templates/layout.html
templates/show_user.html
templates/show_votes.html
templates/user_settings.html
templates/vote.html

diff --git a/main.py b/main.py
index 8c050b8..8a99adb 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -29,7 +29,7 @@ def teardown_request(exception):
 
 @app.route('/')
 def home():
-    return render_template('index.html')
+    return render_template('index.html', active_button="home")
 
 def query_db(query, args=(), one=False):
     cur = g.db.execute(query, args)
@@ -206,15 +206,17 @@ def del_role(idrole):
 @app.route('/votes/<votes>')
 def show_votes(votes):
     today = date.today()
+    active_button = votes
+    basequery = 'select *, roles.name as rolename from votes join roles on roles.id=votes.id_role'
     if votes == 'all':
-        votes = query_db('select * from votes order by id desc')
+        votes = query_db(basequery + ' order by id desc')
     elif votes == 'archive':
-        votes = query_db('select * from votes where date_end < (?) order by id desc', [today])
+        votes = query_db(basequery + ' where date_end < (?) order by id desc', [today])
     elif votes == 'current':
-        votes = query_db('select * from votes where date_end >= (?) order by id desc', [today])
+        votes = query_db(basequery + ' where date_end >= (?) order by id desc', [today])
     else:
         abort(404)
-    return render_template('show_votes.html', votes=votes)
+    return render_template('show_votes.html', votes=votes, active_button=active_button)
 
 #------
 # Vote
index 29f0045..66fd8e5 100644 (file)
@@ -19,9 +19,9 @@
 <header>
   <div class="btn-toolbar">
     <div class="btn-group">
-      <a class="btn active" href="/">Accueil</a>
-      <a class="btn" href="{{ url_for('show_votes', votes='current') }}">Votes en cours</a>
-      <a class="btn" href="{{ url_for('show_votes', votes='archive') }}">Archives</a>
+      <a class="btn {% if active_button == 'home' %}active{% endif %}" href="/">Accueil</a>
+      <a class="btn {% if active_button == 'current' %}active{% endif %}" href="{{ url_for('show_votes', votes='current') }}">Votes en cours</a>
+      <a class="btn {% if active_button == 'archive' %}active{% endif %}" href="{{ url_for('show_votes', votes='archive') }}">Archives</a>
       {% if session.user and session.user.is_admin %}
       <a href="#" class="btn btn-warning dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a>
       <ul class="dropdown-menu pull-right">
@@ -50,7 +50,7 @@
   </div>
 </header>
 
-<h1 class="page-header">Outil de vote du CA FFDN</h1>
+<h1 class="page-header">Outil de vote du CA FFDN <small>{% block subtitle %}{% endblock %}</small></h1>
 {% with messages = get_flashed_messages(with_categories="true") %}
   {% if messages %}
     {% for category, message in messages %}
@@ -62,7 +62,9 @@
   {% endif %}
 {% endwith %}
 
+<div class="container">
 {% block body %}{% endblock %}
+</div>
 
 </div> <!-- container -->   
   <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
index 9ed3f60..3ce7513 100644 (file)
@@ -1,16 +1,16 @@
 {% extends "layout.html" %}
 {% block body %}
-<h2>{{ session.username }}</h2>
+<h2>{{ session.user.name }}</h2>
 <div class="span8">
   <dl>
     <dt>Email :
-    <dd>{{ session.email }}
+    <dd>{{ session.user.email }}
     <dt>Association :
-    <dd>{{ session.organization }}
+    <dd>{{ session.user.organization }}
     <dt>Groupes :
     <dd><em>à venir</em>
   </dl>
-  <a href="{{ url_for('user_settings', userid=session.userid) }}" class="btn btn-primary">Modifier</a>
+  <a href="{{ url_for('user_settings', userid=session.user.id) }}" class="btn btn-primary">Modifier</a>
 </div>
 {% endblock %}
 
index 5d7442e..90fd1f8 100644 (file)
@@ -1,26 +1,28 @@
 {% extends "layout.html" %}
+{% block subtitle %}
+Liste des votes
+{% endblock %}
 {% block body %}
-  <h2>Liste des votes</h2>
   {% for vote in votes %}
   <article>
-    <div class="well">
-    <h3><a href="{{ url_for('show_vote', idvote=vote.id) }}">{{ vote.title }}</a></h3>
-    <hr />
-    <div class="row">
-    <div class="span4">
+    <div class="row well">
+      <div class="span4">
+        <h3><a href="{{ url_for('show_vote', idvote=vote.id) }}">{{ vote.title }}</a></h3>
+        <div class="progress progress-striped">
+          <div class="bar" style="width: 60{{ vote.percent }}%;"></div>
+        </div>
+      </div>
+      <div class="span3">
         <h4>Deadline : {{ vote.date_end }} </h4>
-        <br />
-    <div class="progress progress-striped">
-        <div class="bar"
-            style="width: {{ vote.pourcent }}%;"></div>
-    </div></div>
-    <div class="span4">  
-        <h4>Documents</h4>
+        <h4>Groupe : {{ vote.rolename }}</h4>
+        <h4>Categorie : {{ vote.category }}</h4>
+      </div>
+      <div class="span3">
+      <h4>Notes</h4>
+      <p>
+      {{ vote.description|safe }}
+      </p>
     </div>
-    <div class="span4">
-    <h4>Notes</h4>
-        {{ vote.description|safe }}
-    </div></div></div>
   </article>
   {% else %}
   <div class="alert">Il n'y a pas encore de votes. Désolé.</div>
index 85da44c..a4d497a 100644 (file)
@@ -3,25 +3,25 @@
 <h2>{{ session.username }}</h2>
 <div class="row">
   <div class="span6 well">
-    <form class="form-horizontal" action="{{ url_for('user_settings', userid=session.userid) }}" method="post">
+    <form class="form-horizontal" action="{{ url_for('user_settings', userid=session.user.id) }}" method="post">
     <fieldset><legend>Mise à jour du profil utilisateur</legend>
       <div class="alert"><strong>Attention :</strong> À l'issue de ce formulaire, vous devrez vous reconnecter</div>
       <div class="control-group">
         <label class="control-label" for="email">E-mail</label>
         <div class="controls">
-            <input type="text" name="email" id="email" value="{{ session.email }}"/>
+            <input type="text" name="email" id="email" value="{{ session.user.email }}"/>
         </div>
       </div>
       <div class="control-group">
           <label class="control-label" for="name">Nom</label>
           <div class="controls">
-              <input type="text" name="name" id="name" value="{{ session.username }}" />
+              <input type="text" name="name" id="name" value="{{ session.user.name }}" />
           </div>
       </div>
       <div class="control-group">
         <label class="control-label" for="organization">Association</label>
         <div class="controls">
-            <input type="text" name="organization" id="organization" value="{{ session.organization }}"/>
+            <input type="text" name="organization" id="organization" value="{{ session.user.organization }}"/>
         </div>
       </div>
       <!--<label for="password">Mot de passe</label>
@@ -35,7 +35,7 @@
   </div>
 
   <div class="span5 well">
-    <form class="form-horizontal" action="{{ url_for('user_password', userid=session.userid) }}" method="post">
+    <form class="form-horizontal" action="{{ url_for('user_password', userid=session.user.id) }}" method="post">
     <fieldset><legend>Modification du mot de passe</legend>
       <div class="control-group">
         <label class="control-label" for="password">Mot de passe</label>
index 3ebec2a..30602cb 100644 (file)
@@ -59,7 +59,7 @@
 <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>Deadline le <dd><code>{{ vote.date_end }}</code>
   <dt>Groupe <dd><code>{{ vote.rolename }}</code>
   <dt>Catégorie <dd><code>{{ vote.category }}</code>
 </dl>