Commit f3dbebc25492db6a31fd217f646ecb0b5e767070
1 parent
96346598
Exists in
master
and in
4 other branches
New agent relationships to show in templates
Showing
2 changed files
with
13 additions
and
5 deletions
Show diff stats
app/main/templates/agent.html
... | ... | @@ -28,13 +28,13 @@ |
28 | 28 | <dt class="col-sm-2 text-right"></dt> |
29 | 29 | <dd class="col-sm-10 text-left"></dd> |
30 | 30 | <dt class="col-sm-2 text-right">Statut :</dt> |
31 | - <dd class="col-sm-10 text-left">{{agent.status_id}}</dd> | |
31 | + <dd class="col-sm-10 text-left">{{agent.status.name}}</dd> | |
32 | 32 | <dt class="col-sm-2 text-right">Organisme :</dt> |
33 | - <dd class="col-sm-10 text-left">{{agent.company_id}}</dd> | |
33 | + <dd class="col-sm-10 text-left">{{agent.company.name}}</dd> | |
34 | 34 | <dt class="col-sm-2 text-right">Corps :</dt> |
35 | 35 | <dd class="col-sm-10 text-left"></dd> |
36 | 36 | <dt class="col-sm-2 text-right">BAP :</dt> |
37 | - <dd class="col-sm-10 text-left">{{agent.bap_id}}</dd> | |
37 | + <dd class="col-sm-10 text-left">{{agent.bap.name}}</dd> | |
38 | 38 | {# TODO: puth different spacing #} |
39 | 39 | <dt class="col-sm-2 text-right"></dt> |
40 | 40 | <dd class="col-sm-10 text-left"></dd> | ... | ... |
app/models.py
... | ... | @@ -46,33 +46,41 @@ class ProjectLabel(db.Model): |
46 | 46 | class AgentBap(db.Model): |
47 | 47 | id = db.Column(db.Integer, primary_key=True) |
48 | 48 | name = db.Column(db.String(16)) |
49 | + agents = relationship("Agent", back_populates="bap") | |
49 | 50 | |
50 | 51 | |
51 | 52 | class AgentGrade(db.Model): |
52 | 53 | id = db.Column(db.Integer, primary_key=True) |
53 | 54 | name = db.Column(db.String(16)) |
55 | + agents = relationship("Agent", back_populates="grade") | |
54 | 56 | |
55 | 57 | |
56 | 58 | class AgentStatus(db.Model): |
57 | 59 | id = db.Column(db.Integer, primary_key=True) |
58 | 60 | name = db.Column(db.String(16)) |
61 | + agents = relationship("Agent", back_populates="status") | |
59 | 62 | |
60 | 63 | |
61 | 64 | class Company(db.Model): |
62 | 65 | id = db.Column(db.Integer, primary_key=True) |
63 | 66 | name = db.Column(db.String(16)) |
67 | + agents = relationship("Agent", back_populates="company") | |
64 | 68 | |
65 | 69 | |
66 | 70 | class Agent(db.Model): |
67 | 71 | id = db.Column(db.Integer, primary_key=True) |
68 | 72 | firstname = db.Column(db.String(100)) |
69 | 73 | secondname = db.Column(db.String(100)) |
74 | + virtual = db.Column(db.Integer) # integer boolean | |
75 | + permanent = db.Column(db.Integer) # integer boolean | |
70 | 76 | company_id = db.Column(db.Integer, db.ForeignKey('company.id')) |
71 | 77 | grade_id = db.Column(db.Integer, db.ForeignKey('agent_grade.id')) |
72 | 78 | status_id = db.Column(db.Integer, db.ForeignKey('agent_status.id')) |
73 | 79 | bap_id = db.Column(db.Integer, db.ForeignKey('agent_bap.id')) |
74 | - virtual = db.Column(db.Integer) # integer boolean | |
75 | - permanent = db.Column(db.Integer) # integer boolean | |
80 | + grade = relationship("AgentGrade", back_populates="agents") | |
81 | + bap = relationship("AgentBap", back_populates="agents") | |
82 | + status = relationship("AgentStatus", back_populates="agents") | |
83 | + company = relationship("Company", back_populates="agents") | |
76 | 84 | |
77 | 85 | |
78 | 86 | class Service(db.Model): | ... | ... |