Blame view

app/main/routes.py 1.96 KB
8bd0f3cb   hitier   Fix #25: Flask Bl...
1
2
3
4
from flask import render_template

from . import bp

6cbf4b75   hitier   Periods list
5
from app.models import Agent, Project, Service, Capacity, Period
d6836d5e   hitier   Agents list
6

8bd0f3cb   hitier   Fix #25: Flask Bl...
7
8
9

@bp.route('/')
def index():
a7e64a99   hitier   Services list
10
11
12
13
14
15
16
17
18
    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
6cbf4b75   hitier   Periods list
19
    return render_template('services.html', subtitle="Liste des services ({})".format(num_services),
a7e64a99   hitier   Services list
20
                           services=all_services)
d6836d5e   hitier   Agents list
21
22


3dae0d18   hitier   Projects list
23
24
25
26
27
28
@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
a7e64a99   hitier   Services list
29
    return render_template('projects.html', subtitle="Liste des projets ({})".format(num_projects),
3dae0d18   hitier   Projects list
30
31
                           projects=all_projects)

a7e64a99   hitier   Services list
32

d6836d5e   hitier   Agents list
33
34
35
36
37
38
@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
a7e64a99   hitier   Services list
39
    return render_template('agents.html', subtitle="Liste des agents ({})".format(num_agents),
d6836d5e   hitier   Agents list
40
                           agents=all_agents)
980708a2   hitier   Capacities list
41
42
43
44
45
46
47
48
49

@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)
6cbf4b75   hitier   Periods list
50
51
52
53
54
55
56
57
58

@bp.route('/periods')
def periods():
    # get capacities list
    all_periods = Period.query.order_by(Period.name).all()
    num_periods = len(all_periods)
    # pass to template
    return render_template('periods.html', subtitle="Liste des périodes ({})".format(num_periods),
                           periods=all_periods)
412b041b   hitier   Add charge
59
60
61
62

@bp.route('/add_charge')
def add_charge():
    return render_template('charge.html', subtitle="Affecter un agent")