Commit 61e60a1fbb9c3ede574524dd45c4f536102f0066
1 parent
770d2129
Exists in
master
and in
4 other branches
Now add default capacity
Showing
1 changed file
with
10 additions
and
4 deletions
Show diff stats
app/commands/commands.py
... | ... | @@ -43,8 +43,8 @@ def feed_from_irap(csv_file_name): |
43 | 43 | secondname_key = 'prénom' |
44 | 44 | project_key = 'PROJETS' |
45 | 45 | service_key = 'Groupe métier' |
46 | - typology_title = 'TYPOLOGIE' | |
47 | - thematic_title = 'thématique' | |
46 | + # typology_title = 'TYPOLOGIE' | |
47 | + # thematic_title = 'thématique' | |
48 | 48 | |
49 | 49 | # Get the columns values |
50 | 50 | # |
... | ... | @@ -82,13 +82,18 @@ def feed_from_irap(csv_file_name): |
82 | 82 | db.session.commit() |
83 | 83 | |
84 | 84 | # Feed periods names |
85 | - # Todo: should come from year column name | |
85 | + # Todo: are statically built, | |
86 | + # should come from year column name. | |
86 | 87 | # |
87 | 88 | for p in range(2011, 2030): |
88 | 89 | n_p = Period(name=f"{p}") |
89 | 90 | db.session.add(n_p) |
90 | 91 | db.session.commit() |
91 | 92 | |
93 | + # Add one default capacity | |
94 | + db.session.add(Capacity(name="Travailleur")) | |
95 | + db.session.commit() | |
96 | + | |
92 | 97 | # Now feed the charges. |
93 | 98 | # |
94 | 99 | # At least one for each csv row |
... | ... | @@ -98,6 +103,7 @@ def feed_from_irap(csv_file_name): |
98 | 103 | p = Project.query.filter(Project.name == r[project_key]).one() |
99 | 104 | a = Agent.query.filter(Agent.firstname == r[firstname_key], Agent.secondname == r[secondname_key]).one() |
100 | 105 | s = Service.query.filter(Service.name == r[service_key]).one() |
106 | + c = Capacity.query.first() | |
101 | 107 | for period_name in range(2011, 2030): |
102 | 108 | t = Period.query.filter(Period.name == period_name).one() |
103 | 109 | charge = r[f"{period_name}"] |
... | ... | @@ -110,7 +116,7 @@ def feed_from_irap(csv_file_name): |
110 | 116 | n_c = Charge(agent_id=a.id, |
111 | 117 | project_id=p.id, |
112 | 118 | service_id=s.id, |
113 | - # capacity_id=0, | |
119 | + capacity_id=c.id, | |
114 | 120 | period_id=t.id, |
115 | 121 | charge_rate=charge) |
116 | 122 | db.session.add(n_c) | ... | ... |