tester enregistrer rdf_edit.pt

This commit is contained in:
2019-03-14 17:05:26 +01:00
parent 334cc1fca4
commit 58755c979d
3 changed files with 110 additions and 39 deletions

View File

@@ -184,7 +184,7 @@ def insert_rapport(request,nodossier,logged_in):
societe = nodossier[0:2] societe = nodossier[0:2]
nochantier = nodossier[3:] nochantier = nodossier[3:]
query = """REPLACE INTO dem_rdf (societe, nochantier, cd_cli, nomcli, c_qualite, c_nom, c_adr, c_adr2, c_cp, c_ville, c_tel1, c_telp, nosin, auteur_code) query = """INSERT INTO dem_rdf (societe, nochantier, cd_cli, nomcli, c_qualite, c_nom, c_adr, c_adr2, c_cp, c_ville, c_tel1, c_telp, nosin, auteur_code)
SELECT societe, no_id, cd_cli, nomcli, c_qualite, c_nom, c_adr, c_adr2, c_cp, c_ville, c_tel1, c_telp, nosin, :auteur_code FROM dem_devis WHERE societe = :societe AND no_id = :nochantier;""" SELECT societe, no_id, cd_cli, nomcli, c_qualite, c_nom, c_adr, c_adr2, c_cp, c_ville, c_tel1, c_telp, nosin, :auteur_code FROM dem_devis WHERE societe = :societe AND no_id = :nochantier;"""
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'auteur_code': logged_in}) execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'auteur_code': logged_in})

View File

@@ -38,19 +38,23 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="rapport">Compte-rendu :&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="rapport">Compte-rendu :&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="rapport" tal:attributes="checked rapport.rapport=='Définitif'">Définitif <input type="radio" name="rapport" value="Définitif"
tal:attributes="checked rapport.rapport=='Définitif'">Définitif
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="rapport" tal:attributes="checked rapport.rapport=='Provisoire'">Provisoire <input type="radio" name="rapport" value="Provisoire"
tal:attributes="checked rapport.rapport=='Provisoire'">Provisoire
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="statut_proprio">Statut :&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="statut_proprio">Statut :&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="statut_proprio" tal:attributes="checked rapport.statut_proprio=='Propriétaire'">Propriétaire <input type="radio" name="statut_proprio" value="Propriétaire"
tal:attributes="checked rapport.statut_proprio=='Propriétaire'">Propriétaire
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="statut_proprio" tal:attributes="checked rapport.statut_proprio=='Non Propriétaire'">Non propriétaire <input type="radio" name="statut_proprio" value="Non propriétaire"
tal:attributes="checked rapport.statut_proprio=='Non Propriétaire'">Non propriétaire
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -91,10 +95,10 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="anti_retour">Le bien sinistré est-il protégé par un dispositif anti-retour ?&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="anti_retour">Le bien sinistré est-il protégé par un dispositif anti-retour ?&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="anti_retour" tal:attributes="checked rapport.anti_retour=='NON'">NON <input type="radio" name="anti_retour" value="NON" tal:attributes="checked rapport.anti_retour=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="anti_retour" tal:attributes="checked rapport.anti_retour=='OUI'">OUI <input type="radio" name="anti_retour" value="OUI" tal:attributes="checked rapport.anti_retour=='OUI'">OUI
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -124,10 +128,10 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="voisin">Les dommages sont-ils causés par un bâtiment voisin ?&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="voisin">Les dommages sont-ils causés par un bâtiment voisin ?&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="voisin" tal:attributes="checked rapport.voisin=='NON'">NON <input type="radio" name="voisin" value="NON" tal:attributes="checked rapport.voisin=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="voisin" tal:attributes="checked rapport.voisin=='OUI'">OUI <input type="radio" name="voisin" value="OUI" tal:attributes="checked rapport.voisin=='OUI'">OUI
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -161,38 +165,52 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="detection_fuite">Détection de la fuite :&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="detection_fuite">Détection de la fuite :&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="detection_fuite" tal:attributes="checked rapport.detection_fuite=='Destructif'">Destructif <input type="radio" name="detection_fuite" value="Destructif"
tal:attributes="checked rapport.detection_fuite=='Destructif'">Destructif
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="detection_fuite" tal:attributes="checked rapport.detection_fuite=='Non destructif'">Non destructif <input type="radio" name="detection_fuite" value="Non destructif"
tal:attributes="checked rapport.detection_fuite=='Non destructif'">Non destructif
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label">Mesures d'humidité :&nbsp;&nbsp;&nbsp;</label> <label class="control-label">Mesures d'humidité :&nbsp;&nbsp;&nbsp;</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.sonde_capa}">Sonde capacitive</label> <label class="checkbox-inline"><input type="checkbox" name="sonde_capa" value="${rapport.sonde_capa}"
<label class="checkbox-inline"><input type="checkbox" value="${rapport.sonde_cond}">Sonde à conductivité électrique</label> tal:attributes="checked rapport.sonde_capa != 0 and 'checked' or None">Sonde capacitive</label>
<label class="checkbox-inline"><input type="checkbox" name="sonde_cond" value="${rapport.sonde_cond}"
tal:attributes="checked rapport.sonde_cond != 0 and 'checked' or None">Sonde à conductivité électrique</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label">Test de réseaux :&nbsp;&nbsp;&nbsp;</label> <label class="control-label">Test de réseaux :&nbsp;&nbsp;&nbsp;</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.test_mano}">Système manométrique</label> <label class="checkbox-inline"><input type="checkbox" name="test_mano" value="${rapport.test_mano}"
<label class="checkbox-inline"><input type="checkbox" value="${rapport.test_gaz}">Gaz traceur</label> tal:attributes="checked rapport.test_mano != 0 and 'checked' or None">Système manométrique</label>
<label class="checkbox-inline"><input type="checkbox" name="test_gaz" value="${rapport.test_gaz}"
tal:attributes="checked rapport.test_gaz != 0 and 'checked' or None">Gaz traceur</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label">Visualisation :&nbsp;&nbsp;&nbsp;</label> <label class="control-label">Visualisation :&nbsp;&nbsp;&nbsp;</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.visu_camera}">Caméra infrarouge</label> <label class="checkbox-inline"><input type="checkbox" name="visu_camera" value="${rapport.visu_camera}"
<label class="checkbox-inline"><input type="checkbox" value="${rapport.visu_endoscope}">Endoscope à fibre optique</label> tal:attributes="checked rapport.visu_camera != 0 and 'checked' or None">Caméra infrarouge</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.visu_tele}">Endoscope à fibre optique</label> <label class="checkbox-inline"><input type="checkbox" name="visu_endoscope" value="${rapport.visu_endoscope}"
tal:attributes="checked rapport.visu_endoscope != 0 and 'checked' or None">Endoscope à fibre optique</label>
<label class="checkbox-inline"><input type="checkbox" name="visu_tele" value="${rapport.visu_tele}"
tal:attributes="checked rapport.visu_tele != 0 and 'checked' or None">Endoscope à fibre optique</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label">Recherche de réseaux :&nbsp;&nbsp;&nbsp;</label> <label class="control-label">Recherche de réseaux :&nbsp;&nbsp;&nbsp;</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.rech_magnetique}">Système électro magnétique<>/label> <label class="checkbox-inline"><input type="checkbox" name="rech_magnetique" value="${rapport.rech_magnetique}"
<label class="checkbox-inline"><input type="checkbox" value="${rapport.rech_accoustique}">Système électro accoustique</label> tal:attributes="checked rapport.rech_magnetique != 0 and 'checked' or None">Système électro magnétique<>/label>
<label class="checkbox-inline"><input type="checkbox" name="rech_accoustique" value="${rapport.rech_accoustique}"
tal:attributes="checked rapport.rech_accoustique != 0 and 'checked' or None">Système électro accoustique</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label">Tests d'étanchéité :&nbsp;&nbsp;&nbsp;</label> <label class="control-label">Tests d'étanchéité :&nbsp;&nbsp;&nbsp;</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.test_accoustique}">Ecoute électro accoustique</label> <label class="checkbox-inline"><input type="checkbox" name="test_accoustique" value="${rapport.test_accoustique}"
<label class="checkbox-inline"><input type="checkbox" value="${rapport.test_mise_en_eau}">Mise en eau</label> tal:attributes="checked rapport.test_accoustique != 0 and 'checked' or None">Ecoute électro accoustique</label>
<label class="checkbox-inline"><input type="checkbox" value="${rapport.test_fumigenes}">Fumigènes</label> <label class="checkbox-inline"><input type="checkbox" name="test_mise_en_eau" value="${rapport.test_mise_en_eau}"
tal:attributes="checked rapport.test_mise_en_eau != 0 and 'checked' or None">Mise en eau</label>
<label class="checkbox-inline"><input type="checkbox" name="test_fumigenes" value="${rapport.test_fumigenes}"
tal:attributes="checked rapport.test_fumigenes != 0 and 'checked' or None">Fumigènes</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="descr_detect">Descriptif de la détection</label> <label class="control-label" for="descr_detect">Descriptif de la détection</label>
@@ -208,10 +226,10 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="visite1ere">La réparation est-elle réalisée dans le cadre de la 1ère visite ?&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="visite1ere">La réparation est-elle réalisée dans le cadre de la 1ère visite ?&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="visite1ere" tal:attributes="checked rapport.visite1ere=='NON'">NON <input type="radio" name="visite1ere" value="NON" tal:attributes="checked rapport.visite1ere=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="visite1ere" tal:attributes="checked rapport.visite1ere=='OUI'">OUI <input type="radio" name="visite1ere" value="OUI" tal:attributes="checked rapport.visite1ere=='OUI'">OUI
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -227,37 +245,39 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="blocage_acces">Impossibilité d'accès dans le local où la recherche doi être réalisée&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="blocage_acces">Impossibilité d'accès dans le local où la recherche doi être réalisée&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_acces" tal:attributes="checked rapport.blocage_acces=='NON'">NON <input type="radio" name="blocage_acces" value="NON" tal:attributes="checked rapport.blocage_acces=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_acces" tal:attributes="checked rapport.blocage_acces=='OUI'">OUI <input type="radio" name="blocage_acces" value="OUI" tal:attributes="checked rapport.blocage_acces=='OUI'">OUI
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="blocage_rdf_differente">Nécessité de faire une recherchede fuite destructive dans le local du responsable différent de la victime&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="blocage_rdf_differente">Nécessité de faire une recherchede fuite destructive dans le local du responsable différent de la victime&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_rdf_differente" tal:attributes="checked rapport.blocage_rdf_differente=='NON'">NON <input type="radio" name="blocage_rdf_differente" value="NON" tal:attributes="checked rapport.blocage_rdf_differente=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_rdf_differente" tal:attributes="checked rapport.blocage_rdf_differente=='OUI'">OUI <input type="radio" name="blocage_rdf_differente" value="OUI" tal:attributes="checked rapport.blocage_rdf_differente=='OUI'">OUI
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="blocage_rdf_infructueuse">Recherche de fuite infructueuse&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="blocage_rdf_infructueuse">Recherche de fuite infructueuse&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_rdf_infructueuse" tal:attributes="checked rapport.blocage_rdf_infructueuse=='NON'">NON <input type="radio" name="blocage_rdf_infructueuse" value="NON"
tal:attributes="checked rapport.blocage_rdf_infructueuse=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_rdf_infructueuse" tal:attributes="checked rapport.blocage_rdf_infructueuse=='OUI'">OUI <input type="radio" name="blocage_rdf_infructueuse" value="OUI"
tal:attributes="checked rapport.blocage_rdf_infructueuse=='OUI'">OUI
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="blocage_pluralite">Pluralité de locaux sinistrés autre que le local à l'origine de la fuite&nbsp;&nbsp;&nbsp;</label> <label class="control-label" for="blocage_pluralite">Pluralité de locaux sinistrés autre que le local à l'origine de la fuite&nbsp;&nbsp;&nbsp;</label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_pluralite" tal:attributes="checked rapport.blocage_pluralite=='NON'">NON <input type="radio" name="blocage_pluralite" value="NON" tal:attributes="checked rapport.blocage_pluralite=='NON'">NON
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="blocage_pluralite" tal:attributes="checked rapport.blocage_pluralite=='OUI'">OUI <input type="radio" name="blocage_pluralite" value="OUI" tal:attributes="checked rapport.blocage_pluralite=='OUI'">OUI
</label> </label>
</div> </div>

View File

@@ -328,13 +328,15 @@ def rdf_edit(request):
date_inter = request.matchdict['date_inter'] date_inter = request.matchdict['date_inter']
if date_inter == 'new': if date_inter == 'new':
# creer un nouveau rapport
insert_rapport(request, nodossier, logged_in)
date_inter = date.today().strftime('%Y-%m-%d') date_inter = date.today().strftime('%Y-%m-%d')
rapport = get_rapport_by_no(request, nodossier, date_inter)
if not rapport:
# creer un nouveau rapport
insert_rapport(request, nodossier, logged_in)
else:
# lire le rapport
rapport = get_rapport_by_no(request, nodossier, date_inter)
url = request.route_url('rdf_edit', nodossier=nodossier, date_inter=date_inter) url = request.route_url('rdf_edit', nodossier=nodossier, date_inter=date_inter)
# lire le rapport
rapport = get_rapport_by_no(request, nodossier, date_inter)
caracteristiques = ["Maison individuelle", "Immeuble collectif", "Copropriété", "Commerce", "Bureaux"] caracteristiques = ["Maison individuelle", "Immeuble collectif", "Copropriété", "Commerce", "Bureaux"]
equipements = get_rdf_causes(request, 'C01') equipements = get_rdf_causes(request, 'C01')
@@ -350,6 +352,55 @@ def rdf_edit(request):
for param, db_value in rapport.items(): for param, db_value in rapport.items():
if param in request.params and request.params[param] != db_value: if param in request.params and request.params[param] != db_value:
new_values[param] = request.params[param] new_values[param] = request.params[param]
# case à cocher ?
if 'sonde_capa' in request.params:
new_values['sonde_capa'] = 1
else:
new_values['sonde_capa'] = 0
if 'sonde_cond' in request.params:
new_values['sonde_cond'] = 1
else:
new_values['sonde_cond'] = 0
if 'test_mano' in request.params:
new_values['test_mano'] = 1
else:
new_values['test_mano'] = 0
if 'test_gaz' in request.params:
new_values['test_gaz'] = 1
else:
new_values['test_gaz'] = 0
if 'visu_camera' in request.params:
new_values['visu_camera'] = 1
else:
new_values['visu_camera'] = 0
if 'visu_endoscope' in request.params:
new_values['visu_endoscope'] = 1
else:
new_values['visu_endoscope'] = 0
if 'visu_tele' in request.params:
new_values['visu_tele'] = 1
else:
new_values['visu_tele'] = 0
if 'rech_magnetique' in request.params:
new_values['rech_magnetique'] = 1
else:
new_values['rech_magnetique'] = 0
if 'rech_accoustique' in request.params:
new_values['rech_accoustique'] = 1
else:
new_values['rech_accoustique'] = 0
if 'test_accoustique' in request.params:
new_values['test_accoustique'] = 1
else:
new_values['test_accoustique'] = 0
if 'test_mise_en_eau' in request.params:
new_values['test_mise_en_eau'] = 1
else:
new_values['test_mise_en_eau'] = 0
if 'test_fumigenes' in request.params:
new_values['test_fumigenes'] = 1
else:
new_values['test_fumigenes'] = 0
if new_values: if new_values:
update_rapport(request, nodossier, date_inter, new_values) update_rapport(request, nodossier, date_inter, new_values)