ajout suppression des photos, bouton valider rapport

This commit is contained in:
2019-04-22 18:11:53 +02:00
parent e3c62af198
commit 18fb3c5ceb
9 changed files with 118 additions and 55 deletions

View File

@@ -13,7 +13,7 @@ def main(global_config, **settings):
"""
# declarations
session_factory = SignedCookieSessionFactory('Ty6sIUe9')
authn_policy = AuthTktAuthenticationPolicy('Ty6sIUe8', callback=groupfinder, hashalg='sha512')
authn_policy = AuthTktAuthenticationPolicy('Ty6sIUe8', callback=groupfinder, hashalg='sha512', timeout=36000)
authz_policy = ACLAuthorizationPolicy()
mailer_factory_from_settings(settings)

View File

@@ -153,10 +153,13 @@ def get_photos(request, nochantier, norapport):
query = "SELECT * FROM dossier_attaches WHERE nomrep = 'DOCS_ATTACHES' AND societe = 'PL' AND nochantier = :nochantier AND nodossier = :norapport ORDER BY cree_le;"
results = request.dbsession.execute(query, {'nochantier': nochantier, 'norapport': norapport}).fetchall()
return results
def delete_photos(request, nochantier, norapport, nomfic):
query = "DELETE FROM dossier_attaches WHERE nomrep='DOCS_ATTACHES' AND societe='PL' AND nochantier=:nochantier AND nodossier=:norapport AND nomfichier=:nomfic;"
execute_query(request, query, {'nochantier': nochantier, 'norapport': norapport, 'nomfic': nomfic})
def update_dossier(request, nodossier, new_values):
societe = nodossier[0:2]
nochantier = int(nodossier[3:])
@@ -238,5 +241,9 @@ def update_rapport(request, nodossier, date_inter, new_values):
def delete_rapport(request, no_id):
query = "DELETE FROM dem_rdf WHERE no_id = :no_id"
query = "DELETE FROM dem_rdf WHERE no_id = :no_id"
execute_query(request, query, {'no_id': no_id})
def validate_rapport(request, no_id):
query = "UPDATE dem_rdf SET date_relu=CURRENT_DATE WHERE no_id = :no_id"
execute_query(request, query, {'no_id': no_id})

View File

@@ -19,6 +19,7 @@ def includeme(config):
config.add_route('dossier_selected', '/dossier_selected/{goto}/{date}/{nodossier}')
config.add_route('dossier_view', '/dossier_view/{nodossier}')
config.add_route('rdf_edit','/rdf_edit/{nodossier}/{date_inter}')
config.add_route('rdf_imgdel','/rdf_imgdel/{nochantier}/{norapport}/{nomfic}')
config.add_route('rdf_list','/rdf_list')
config.add_route('rdf_rapport','/rdf_rapport/{no_id}')
config.add_route('rdf_view','/rdf_view/{no_id}')

View File

@@ -193,8 +193,8 @@
<td>
<a href="/rdf_view/${rapport.no_id}">${rapport.no_id}</a>
</td>
<td>${rapport.date_inter.strftime('%Y-%m-%d')}</td>
<td tal:condition="rapport.date_rapport">${rapport.date_rapport.strftime('%d-%m-%Y')}</td>
<td>${rapport.date_inter.strftime('%d-%m-%Y')}</td>
<td tal:condition="rapport.date_rapport">${rapport.date_rapport.strftime('%d-%m-%Y')}</td>
<td tal:condition="not rapport.date_rapport"></td>
<td>${rapport.C_QUALITE} ${rapport.C_NOM}</td>
<td>${rapport.NOSIN}</td>

View File

@@ -9,14 +9,14 @@
<table id="users_list" class="table table-striped table-bordered">
<thead>
<tr>
<th>Dossier</th>
<th>Date interv.</th>
<th>Date rapport</th>
<th>Rapport</th>
<th>Intervenu</th>
<th>Validé</th>
<th>Généré</th>
<th>Chantier</th>
<th>Client</th>
<th>No sinistre</th>
<th>Auteur</th>
<th>Rapport</th>
</tr>
</thead>
</table>
@@ -40,10 +40,11 @@
{ "targets": 0,
"render": function (data, type, row, meta) {
// ajouter un link vers le formulaire
return '<a href="/rdf_view/' + row[7] + '">' + data + '</a>';
return '<a href="/rdf_view/' + data + '">' + data + '</a>';
},
},
]
],
order: [[ 0, "desc" ]],
});
});

View File

@@ -289,8 +289,8 @@
<br />
<div tal:condition="pt_name=='rdf_view'">
<p>
<a href="${request.application_url}/upload_img/${norapport}" class="btn btn-success" role="button">
<span class="glyphicon glyphicon-cloud-upload"></span>&nbsp;Ajouter une photo</a>
<a href="${request.application_url}/upload_img/${norapport}" class="btn btn-primary" role="button">
<span class="glyphicon glyphicon-picture"></span>&nbsp;Gérer les photos</a>
</p>
<br />
</div>
@@ -308,7 +308,7 @@
<table class="table table-condensed ">
<tr>
<td>
<td width="40%">
<label>Date du rapport :</label>&nbsp;&nbsp;${date_rapport}
<br />
<br />
@@ -316,8 +316,11 @@
<br />${rapport.auteur_nom}
<br />
<br />
<label>Relu par le superviseur :</label>
<br />Jean-Marc PENEL
<div tal:condition="date_relu!=''">
<label>Relu par le superviseur :</label>
<br />Jean-Marc PENEL
<br />le ${date_relu}
</div>
</td>
<td>
<label>Signature du client :</label>
@@ -334,12 +337,17 @@
<span class="glyphicon glyphicon-arrow-left"></span> Retour Dossier</a>
<a class="btn btn-primary" href="/rdf_edit/${nodossier}/${rapport.date_inter.strftime('%Y-%m-%d')}">
<span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<button class="btn btn-danger" type="submit" name="form.delete" tal:condition="not rapport.signature_svg and date_rapport==''">
<button class="btn btn-danger" type="submit" name="form.delete" tal:condition="not rapport.signature_svg and date_relu==''">
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
<a class="btn btn-default" href="/rdf_rapport/${rapport.no_id}">
<span class="glyphicon glyphicon-file"></span> Aperçu PDF</a>
<button class="btn btn-warning" type="submit" name="form.generate">
<span class="glyphicon glyphicon-file"></span> Générer PDF</button>
<button class="btn btn-success" type="submit" name="form.validate" tal:condition="(logged_in=='JMP' or logged_in=='CAO') and date_relu==''">
<span class="glyphicon glyphicon-remove"></span> Valider</button>
<div tal:condition="(logged_in=='MD' or logged_in=='CAO') and date_relu!=''">
<br />
<a class="btn btn-default" href="/rdf_rapport/${rapport.no_id}">
<span class="glyphicon glyphicon-file"></span> Aperçu PDF</a>
<button class="btn btn-warning" type="submit" name="form.generate">
<span class="glyphicon glyphicon-file"></span> Générer PDF</button>
</div>
</div>
</div>

View File

@@ -1,38 +1,59 @@
<metal:block use-macro="main_template">
<div metal:fill-slot="content">
<div class="row">
<form id="upload_doc-form" action="${url}" method="post" accept-charset="utf-8" enctype="multipart/form-data"
data-fv-framework="bootstrap"
data-fv-icon-valid="glyphicon glyphicon-ok"
data-fv-icon-invalid="glyphicon glyphicon-remove"
data-fv-icon-validating="glyphicon glyphicon-refresh">
<div class="form-group">
<label for="uploadfile">Veuillez séléctionner un fichier</label>
<input id="uploadfile" name="filename" type="file" value="" required />
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<span class="glyphicon glyphicon-plus"></span>&nbsp;AJOUTER UNE PHOTO
</h4>
</div>
<div class="form-group">
<a class="btn btn-default" href="${request.route_url('rdf_view', no_id=norapport)}">
<span class="glyphicon glyphicon-arrow-left"></span> Retour au rapport</a>
<button id="uploadButton" class="btn btn-primary" type="submit" name="form.submitted">
<i class="glyphicon glyphicon-refresh"></i> Télécharger</button>
<div class="panel-body">
<div class="col-sm-6">
<form id="upload_doc-form" action="${url}" method="post" accept-charset="utf-8" enctype="multipart/form-data"
data-fv-framework="bootstrap"
data-fv-icon-valid="glyphicon glyphicon-ok"
data-fv-icon-invalid="glyphicon glyphicon-remove"
data-fv-icon-validating="glyphicon glyphicon-refresh">
<div class="form-group">
<label for="uploadfile">Veuillez séléctionner un fichier</label>
<input id="uploadfile" name="filename" type="file" value="" required />
</div>
<div class="form-group">
<a class="btn btn-default" href="${request.route_url('rdf_view', no_id=norapport)}">
<span class="glyphicon glyphicon-arrow-left"></span> Retour au rapport</a>
<button id="uploadButton" class="btn btn-primary" type="submit" name="form.submitted">
<i class="glyphicon glyphicon-refresh"></i> Télécharger</button>
</div>
</form>
</div>
<div class="col-sm-6 well well-sm">
<ul>
<li>Seuls les documents au format <b>PNG, JPG ou JPEG</b> seront acceptés.</li>
<li>La taille de chaque document ne doit <b>pas dépasser 2 Mo</b>.</li>
</ul>
</div> <!-- row -->
</div>
</form>
</div> <!-- row -->
<div class="row">
<ul>
<li>Seuls les documents au format <b>PNG, JPG ou JPEG</b> seront acceptés.</li>
<li>La taille de chaque document ne doit <b>pas dépasser 2 Mo</b>.</li>
</ul>
</div> <!-- row -->
<div class="panel-heading">
<h4 class="panel-title">
<span class="glyphicon glyphicon-arrow-up"></span>&nbsp;PHOTOS DEJA TELECHARGES
</h4>
</div>
<div class="panel-body">
<form id="upload_doc-form" action="${url}" method="post">
<ul tal:repeat="detail photos">
<li>
${detail.nomfichier} <a href="/rdf_imgdel/${nochantier}/${norapport}/${detail.nomfichier}">[Suppimer cet image]</a>
<img src="${docs_url}${detail.nomrep}/${detail.societe}/${nochantier}/${norapport}/${detail.nomfichier}"
width="700" align="center" />
</li>
</ul>
</form>
</div>
</div>
<h3>Photos déjà téléchargées</h3>
<p tal:repeat="detail photos">
<img src="${docs_url}${detail.nomrep}/${detail.societe}/${nochantier}/${norapport}/${detail.nomfichier}"
width="800" align="center" />
</p>
<script type="text/javascript">
$('#uploadButton').on('click', function(){

View File

@@ -34,7 +34,7 @@
language: {
url: 'https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json'
},
"order": [[ 0, "desc" ]]
order: [[ 0, "desc" ]]
});
});

View File

@@ -394,7 +394,7 @@ def upload_img(request):
photos = get_photos(request, nochantier, norapport)
return {
'page_title': u"Télécharger une photo",
'page_title': u"Gérer les photos",
'url': url,
'nochantier': nochantier,
'norapport': norapport,
@@ -514,13 +514,17 @@ def rdf_list(request):
# construire la liste
liste=[]
for item in items:
if item.date_relu :
date_relu = item.date_relu.strftime('%d-%m-%Y')
else:
date_relu = ''
if item.date_rapport :
date_rapport = item.date_rapport.strftime('%d-%m-%Y')
else:
date_rapport = ''
d = (item.nochantier, item.date_inter.strftime('%d-%m-%Y'), date_rapport, '%s %s' % (item.C_QUALITE, item.C_NOM), item.NOMCLI, item.NOSIN,
item.auteur_code, item.no_id)
d = (item.no_id, item.date_inter.strftime('%d-%m-%Y'), date_relu, date_rapport, '%s - %s %s' % (item.nochantier, item.C_QUALITE, item.C_NOM), item.NOMCLI, item.NOSIN,
item.auteur_code)
liste.append(d)
return {
@@ -537,6 +541,10 @@ def rdf_view(request):
# lire le rapport
rapport = get_rapport_by_no_id(request, norapport)
nodossier = 'PL-' + str(rapport.nochantier)
if rapport.date_relu:
date_relu = rapport.date_relu.strftime('%d-%m-%Y')
else:
date_relu = ''
if rapport.date_rapport:
date_rapport = rapport.date_rapport.strftime('%d-%m-%Y')
else:
@@ -578,6 +586,10 @@ def rdf_view(request):
request.session.flash(u"Le rapport a été génré avec succès.", 'success')
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
if 'form.validate' in request.params:
validate_rapport(request, norapport)
request.session.flash(u"Le rapporta été validé avec succès.", 'success')
if 'form.delete' in request.params:
delete_rapport(request, norapport)
request.session.flash(u"Le rapporta été supprimé avec succès.", 'success')
@@ -593,6 +605,7 @@ def rdf_view(request):
'nochantier': rapport.nochantier,
'norapport': norapport,
'date_rapport': date_rapport,
'date_relu': date_relu,
'photos': photos,
'docs_url': request.static_url(request.registry.settings['mondumas.devfac_url']),
}
@@ -624,3 +637,15 @@ def rdf_rapport(request):
'photos': photos,
'docs_url': request.static_url(request.registry.settings['mondumas.devfac_url']),
}
@view_config(route_name='rdf_imgdel', permission='view')
def rdf_imgdel(request):
logged_in = request.authenticated_userid.upper()
nochantier = request.matchdict['nochantier']
norapport = request.matchdict['norapport']
nomfic = request.matchdict['nomfic']
delete_photos(request, nochantier, norapport, nomfic)
request.session.flash(u"La photo %s a été supprimé avec succès" % (nomfic), 'success')
return HTTPFound(location=request.route_url("upload_img", norapport=norapport))