bug générer demande MAIF + suppression photo

This commit is contained in:
2020-09-17 12:24:49 +02:00
parent 7d81e0be71
commit aae410f574
2 changed files with 15 additions and 7 deletions

View File

@@ -189,6 +189,12 @@ def get_photos(request, nodossier, norapport, nosection):
def delete_photos(request, nodossier, norapport, nosection, nomfic):
societe = nodossier[0:2]
nochantier = int(nodossier[3:])
# supprimer d'abord le fichier
file_path = '%s/%s/%s/%s/%s' % (request.registry.settings['mondumas.devfac_dir'], societe, nochantier, norapport, nomfic)
if os.path.exists(file_path):
os.remove(file_path)
query = "DELETE FROM dossier_attaches WHERE nomrep='DOCS_ATTACHES' AND societe=:societe AND nochantier=:nochantier AND nodossier=:norapport AND nosection=:nosection AND nomfichier=:nomfic;"
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'norapport': norapport, 'nosection': nosection, 'nomfic': nomfic})

View File

@@ -661,6 +661,11 @@ def rdf_view(request):
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
if 'form.delete' in request.params:
# le rapport a-t-il des photos ?
if len(photos1) > 0 or len(photos2) > 0:
request.session.flash(u"Veuillez supprimer les photos avant de supprimer Le rapport.", 'warning')
return HTTPFound(location=url)
delete_rapport(request, norapport)
request.session.flash(u"Le rapport a été supprimé avec succès.", 'success')
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
@@ -734,11 +739,6 @@ def delete_img(request):
else:
url_retour = location=request.route_url("upload_img", norapport=norapport, nosection=nosection)
# supprimer le fichier
file_path = '%s/%s/%s/%s/%s' % (request.registry.settings['mondumas.devfac_dir'], societe, nochantier, norapport, nomfic)
if os.path.exists(file_path):
os.remove(file_path)
delete_photos(request, nodossier, norapport, nosection, nomfic)
request.session.flash(u"La photo %s a été supprimé avec succès" % (nomfic), 'success')
return HTTPFound(url_retour)
@@ -1205,13 +1205,15 @@ def get_pdf_infos1(extracted_file):
no_sinistre = line[:-1]
if line.find('Bénéficiaire des travaux :') == 0:
elt = line[:-1].split(' :')
import pdb;pdb.set_trace()
if len(elt) == 1:
# le nom du chantier est sur la ligne suivante
line = fp.readline()
c_nom = line[:-1]
c_nom = line[:-1]
c_nom = c_nom[:40] # ne prendre que 40 carac
else:
# le nom du chantier est sur la même ligne
c_nom = elt[1].strip()
c_nom = elt[1].strip()[:40]
line = fp.readline()
line = fp.readline()
line = fp.readline()