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,13 +28,13 @@ | ||
28 | <dt class="col-sm-2 text-right"></dt> | 28 | <dt class="col-sm-2 text-right"></dt> |
29 | <dd class="col-sm-10 text-left"></dd> | 29 | <dd class="col-sm-10 text-left"></dd> |
30 | <dt class="col-sm-2 text-right">Statut :</dt> | 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 | <dt class="col-sm-2 text-right">Organisme :</dt> | 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 | <dt class="col-sm-2 text-right">Corps :</dt> | 34 | <dt class="col-sm-2 text-right">Corps :</dt> |
35 | <dd class="col-sm-10 text-left"></dd> | 35 | <dd class="col-sm-10 text-left"></dd> |
36 | <dt class="col-sm-2 text-right">BAP :</dt> | 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 | {# TODO: puth different spacing #} | 38 | {# TODO: puth different spacing #} |
39 | <dt class="col-sm-2 text-right"></dt> | 39 | <dt class="col-sm-2 text-right"></dt> |
40 | <dd class="col-sm-10 text-left"></dd> | 40 | <dd class="col-sm-10 text-left"></dd> |
app/models.py
@@ -46,33 +46,41 @@ class ProjectLabel(db.Model): | @@ -46,33 +46,41 @@ class ProjectLabel(db.Model): | ||
46 | class AgentBap(db.Model): | 46 | class AgentBap(db.Model): |
47 | id = db.Column(db.Integer, primary_key=True) | 47 | id = db.Column(db.Integer, primary_key=True) |
48 | name = db.Column(db.String(16)) | 48 | name = db.Column(db.String(16)) |
49 | + agents = relationship("Agent", back_populates="bap") | ||
49 | 50 | ||
50 | 51 | ||
51 | class AgentGrade(db.Model): | 52 | class AgentGrade(db.Model): |
52 | id = db.Column(db.Integer, primary_key=True) | 53 | id = db.Column(db.Integer, primary_key=True) |
53 | name = db.Column(db.String(16)) | 54 | name = db.Column(db.String(16)) |
55 | + agents = relationship("Agent", back_populates="grade") | ||
54 | 56 | ||
55 | 57 | ||
56 | class AgentStatus(db.Model): | 58 | class AgentStatus(db.Model): |
57 | id = db.Column(db.Integer, primary_key=True) | 59 | id = db.Column(db.Integer, primary_key=True) |
58 | name = db.Column(db.String(16)) | 60 | name = db.Column(db.String(16)) |
61 | + agents = relationship("Agent", back_populates="status") | ||
59 | 62 | ||
60 | 63 | ||
61 | class Company(db.Model): | 64 | class Company(db.Model): |
62 | id = db.Column(db.Integer, primary_key=True) | 65 | id = db.Column(db.Integer, primary_key=True) |
63 | name = db.Column(db.String(16)) | 66 | name = db.Column(db.String(16)) |
67 | + agents = relationship("Agent", back_populates="company") | ||
64 | 68 | ||
65 | 69 | ||
66 | class Agent(db.Model): | 70 | class Agent(db.Model): |
67 | id = db.Column(db.Integer, primary_key=True) | 71 | id = db.Column(db.Integer, primary_key=True) |
68 | firstname = db.Column(db.String(100)) | 72 | firstname = db.Column(db.String(100)) |
69 | secondname = db.Column(db.String(100)) | 73 | secondname = db.Column(db.String(100)) |
74 | + virtual = db.Column(db.Integer) # integer boolean | ||
75 | + permanent = db.Column(db.Integer) # integer boolean | ||
70 | company_id = db.Column(db.Integer, db.ForeignKey('company.id')) | 76 | company_id = db.Column(db.Integer, db.ForeignKey('company.id')) |
71 | grade_id = db.Column(db.Integer, db.ForeignKey('agent_grade.id')) | 77 | grade_id = db.Column(db.Integer, db.ForeignKey('agent_grade.id')) |
72 | status_id = db.Column(db.Integer, db.ForeignKey('agent_status.id')) | 78 | status_id = db.Column(db.Integer, db.ForeignKey('agent_status.id')) |
73 | bap_id = db.Column(db.Integer, db.ForeignKey('agent_bap.id')) | 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 | class Service(db.Model): | 86 | class Service(db.Model): |