Commit 687ef08f95d38c7afae2acd290b28af86e43a8af

Authored by hitier
1 parent ca0797d6

Use checkboxes for boolean fields

app/main/templates/agent.html
@@ -52,8 +52,6 @@ @@ -52,8 +52,6 @@
52 {# TODO: put different spacing #} 52 {# TODO: put different spacing #}
53 <dt class="col-sm-2 text-right"></dt> 53 <dt class="col-sm-2 text-right"></dt>
54 <dd class="col-sm-10 text-left"></dd> 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 <dt class="col-sm-2 text-right">Fiche de poste :</dt> 55 <dt class="col-sm-2 text-right">Fiche de poste :</dt>
58 <dd class="col-sm-10 text-left"></dd> 56 <dd class="col-sm-10 text-left"></dd>
59 {# TODO: put different spacing #} 57 {# TODO: put different spacing #}
app/main/templates/agent_edit.html
@@ -18,9 +18,15 @@ @@ -18,9 +18,15 @@
18 <label for="secondname">Prénom</label> 18 <label for="secondname">Prénom</label>
19 <input class="form-control" id="secondname" name="secondname" type="text" value="{{ agent['secondname'] }}"> 19 <input class="form-control" id="secondname" name="secondname" type="text" value="{{ agent['secondname'] }}">
20 </div> 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 </div> 30 </div>
25 <div class="form-group"> 31 <div class="form-group">
26 <label for="company">Structure</label> 32 <label for="company">Structure</label>
@@ -38,10 +44,6 @@ @@ -38,10 +44,6 @@
38 <label for="bap">Bap</label> 44 <label for="bap">Bap</label>
39 <input class="form-control" id="bap_id" name="bap_id" type="text" value="{{ agent['bap_id'] }}"> 45 <input class="form-control" id="bap_id" name="bap_id" type="text" value="{{ agent['bap_id'] }}">
40 </div> 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 <input class="btn btn-dark" type="submit" value="Valider"> 47 <input class="btn btn-dark" type="submit" value="Valider">
46 </form> 48 </form>
47 {% endblock %} 49 {% endblock %}
@@ -111,7 +111,11 @@ class Agent(db.Model): @@ -111,7 +111,11 @@ class Agent(db.Model):
111 :return: 111 :return:
112 """ 112 """
113 for key in self.export_keys: 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 class Service(db.Model): 121 class Service(db.Model):