ajout suppression des photos, bouton valider rapport
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -153,9 +153,12 @@ 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]
|
||||
@@ -240,3 +243,7 @@ def delete_rapport(request, 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})
|
||||
|
||||
@@ -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}')
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
<td>
|
||||
<a href="/rdf_view/${rapport.no_id}">${rapport.no_id}</a>
|
||||
</td>
|
||||
<td>${rapport.date_inter.strftime('%Y-%m-%d')}</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>
|
||||
|
||||
@@ -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" ]],
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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> Ajouter une photo</a>
|
||||
<a href="${request.application_url}/upload_img/${norapport}" class="btn btn-primary" role="button">
|
||||
<span class="glyphicon glyphicon-picture"></span> 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> ${date_rapport}
|
||||
<br />
|
||||
<br />
|
||||
@@ -316,8 +316,11 @@
|
||||
<br />${rapport.auteur_nom}
|
||||
<br />
|
||||
<br />
|
||||
<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,14 +337,19 @@
|
||||
<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>
|
||||
<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>
|
||||
|
||||
</form>
|
||||
<br />
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
<metal:block use-macro="main_template">
|
||||
<div metal:fill-slot="content">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<span class="glyphicon glyphicon-plus"></span> AJOUTER UNE PHOTO
|
||||
</h4>
|
||||
</div>
|
||||
<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"
|
||||
@@ -20,19 +26,34 @@
|
||||
<i class="glyphicon glyphicon-refresh"></i> Télécharger</button>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- row -->
|
||||
<div class="row">
|
||||
</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>
|
||||
|
||||
<h3>Photos déjà téléchargées</h3>
|
||||
<p tal:repeat="detail photos">
|
||||
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<span class="glyphicon glyphicon-arrow-up"></span> 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="800" align="center" />
|
||||
</p>
|
||||
width="700" align="center" />
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#uploadButton').on('click', function(){
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
language: {
|
||||
url: 'https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json'
|
||||
},
|
||||
"order": [[ 0, "desc" ]]
|
||||
order: [[ 0, "desc" ]]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user