routes.py 1.52 KB
from flask import render_template

from . import bp

from app.models import Agent, Project, Service, Capacity


@bp.route('/')
def index():
    return render_template('index.html', subtitle="Page d'accueil")


@bp.route('/services')
def services():
    # get services list
    all_services = Service.query.order_by(Service.name).all()
    num_services = len(all_services)
    # pass to template
    return render_template('services.html', subtitle="Liste des projets ({})".format(num_services),
                           services=all_services)


@bp.route('/projects')
def projects():
    # get projects list
    all_projects = Project.query.order_by(Project.name).all()
    num_projects = len(all_projects)
    # pass to template
    return render_template('projects.html', subtitle="Liste des projets ({})".format(num_projects),
                           projects=all_projects)


@bp.route('/agents')
def agents():
    # get agents list
    all_agents = Agent.query.order_by(Agent.firstname).all()
    num_agents = len(all_agents)
    # pass to template
    return render_template('agents.html', subtitle="Liste des agents ({})".format(num_agents),
                           agents=all_agents)

@bp.route('/capacities')
def capacities():
    # get capacities list
    all_capacities = Capacity.query.order_by(Capacity.name).all()
    num_capacities = len(all_capacities)
    # pass to template
    return render_template('capacities.html', subtitle="Liste des fonctions ({})".format(num_capacities),
                           capacities=all_capacities)