Commit 687ef08f95d38c7afae2acd290b28af86e43a8af
1 parent
ca0797d6
Exists in
master
and in
4 other branches
Use checkboxes for boolean fields
Showing
3 changed files
with
14 additions
and
10 deletions
Show diff stats
app/main/templates/agent.html
... | ... | @@ -52,8 +52,6 @@ |
52 | 52 | {# TODO: put different spacing #} |
53 | 53 | <dt class="col-sm-2 text-right"></dt> |
54 | 54 | <dd class="col-sm-10 text-left"></dd> |
55 | - <dt class="col-sm-2 text-right">APPRENTI</dt> | |
56 | - <dd class="col-sm-10 text-left"></dd> | |
57 | 55 | <dt class="col-sm-2 text-right">Fiche de poste :</dt> |
58 | 56 | <dd class="col-sm-10 text-left"></dd> |
59 | 57 | {# TODO: put different spacing #} | ... | ... |
app/main/templates/agent_edit.html
... | ... | @@ -18,9 +18,15 @@ |
18 | 18 | <label for="secondname">Prénom</label> |
19 | 19 | <input class="form-control" id="secondname" name="secondname" type="text" value="{{ agent['secondname'] }}"> |
20 | 20 | </div> |
21 | - <div class="form-group"> | |
22 | - <label for="virtual">Virtuel</label> | |
23 | - <input class="form-control" id="virtual" name="virtual" type="text" value="{{ agent['virtual'] }}"> | |
21 | + <div class="form-group form-check form-check-inline"> | |
22 | + <label class="form-check-label" for="virtual">Virtuel</label> | |
23 | + <input class="form-check-input" type="checkbox" id="virtual" name="virtual" | |
24 | + {{ 'checked' if agent['virtual'] == 1 }} value="1"> | |
25 | + </div> | |
26 | + <div class="form-group form-check form-check-inline"> | |
27 | + <label class="form-check-label" for="permanent">Permanent</label> | |
28 | + <input class="form-check-input" type="checkbox" id="permanent" name="permanent" | |
29 | + {{ 'checked' if agent['permanent'] == 1 }} value="1"> | |
24 | 30 | </div> |
25 | 31 | <div class="form-group"> |
26 | 32 | <label for="company">Structure</label> |
... | ... | @@ -38,10 +44,6 @@ |
38 | 44 | <label for="bap">Bap</label> |
39 | 45 | <input class="form-control" id="bap_id" name="bap_id" type="text" value="{{ agent['bap_id'] }}"> |
40 | 46 | </div> |
41 | - <div class="form-group"> | |
42 | - <label for="permanent">Permanent</label> | |
43 | - <input class="form-control" id="permanent" name="permanent" type="text" value="{{ agent['permanent'] }}"> | |
44 | - </div> | |
45 | 47 | <input class="btn btn-dark" type="submit" value="Valider"> |
46 | 48 | </form> |
47 | 49 | {% endblock %} | ... | ... |
app/models.py
... | ... | @@ -111,7 +111,11 @@ class Agent(db.Model): |
111 | 111 | :return: |
112 | 112 | """ |
113 | 113 | for key in self.export_keys: |
114 | - setattr(self, key, form_request.form[key]) | |
114 | + # deal with checked value | |
115 | + if key in ['permanent', 'virtual']: | |
116 | + setattr(self, key, form_request.form.get(key)) | |
117 | + else: | |
118 | + setattr(self, key, form_request.form[key]) | |
115 | 119 | |
116 | 120 | |
117 | 121 | class Service(db.Model): | ... | ... |