Commit d6836d5e64e8c04c69c231f46212148de6bacea2

Authored by hitier
1 parent d2dcb89e

Agents list

app/main/routes.py
... ... @@ -2,7 +2,19 @@ from flask import render_template
2 2  
3 3 from . import bp
4 4  
  5 +from app.models import Agent
  6 +
5 7  
6 8 @bp.route('/')
7 9 def index():
8   - return render_template('index.html', title="Plan de Charge", subtitle="Page d'accueil")
  10 + return render_template('index.html', subtitle="Page d'accueil")
  11 +
  12 +
  13 +@bp.route('/agents')
  14 +def agents():
  15 + # get agents list
  16 + all_agents = Agent.query.order_by(Agent.firstname).all()
  17 + num_agents = len(all_agents)
  18 + # pass to template
  19 + return render_template('agents.html', subtitle="Liste des agents ({})".format(num_agents),
  20 + agents=all_agents)
... ...
app/main/templates/agents.html 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +{% extends "base_page.html" %}
  2 +{% block content %}
  3 +<table class="table table-hover">
  4 + <thead>
  5 + <tr>
  6 + <th scope="col">Nom</th>
  7 + <th scope="col">Prénom</th>
  8 + </tr>
  9 + </thead>
  10 + {% for agent in agents %}
  11 + <tr>
  12 + <td>{{ agent.firstname }}</td>
  13 + <td>{{agent.secondname}}</td>
  14 + </tr>
  15 + {% endfor %}
  16 +</table>
  17 +{% endblock %}
0 18 \ No newline at end of file
... ...
app/templates/base_page.html
... ... @@ -40,7 +40,7 @@
40 40 Agent
41 41 </a>
42 42 <ul aria-expanded="false" class="collapse" id="agent">
43   - <li><a class=" " href="#">Liste des agents</a></li>
  43 + <li><a class=" " href="{{url_for('main.agents')}}">Liste des agents</a></li>
44 44 <li><a class=" disabled" href="#">Statistiques</a></li>
45 45 <li><a class=" disabled" href="#">Liste des responsabilités</a></li>
46 46 <li><a class=" disabled" href="#">Liste des fonctions</a></li>
... ...