ajout suppression des photos, bouton valider rapport
This commit is contained in:
@@ -13,7 +13,7 @@ def main(global_config, **settings):
|
|||||||
"""
|
"""
|
||||||
# declarations
|
# declarations
|
||||||
session_factory = SignedCookieSessionFactory('Ty6sIUe9')
|
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()
|
authz_policy = ACLAuthorizationPolicy()
|
||||||
mailer_factory_from_settings(settings)
|
mailer_factory_from_settings(settings)
|
||||||
|
|
||||||
|
|||||||
@@ -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;"
|
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()
|
results = request.dbsession.execute(query, {'nochantier': nochantier, 'norapport': norapport}).fetchall()
|
||||||
|
|
||||||
return results
|
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):
|
def update_dossier(request, nodossier, new_values):
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
nochantier = int(nodossier[3:])
|
nochantier = int(nodossier[3:])
|
||||||
@@ -238,5 +241,9 @@ def update_rapport(request, nodossier, date_inter, new_values):
|
|||||||
|
|
||||||
def delete_rapport(request, no_id):
|
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})
|
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_selected', '/dossier_selected/{goto}/{date}/{nodossier}')
|
||||||
config.add_route('dossier_view', '/dossier_view/{nodossier}')
|
config.add_route('dossier_view', '/dossier_view/{nodossier}')
|
||||||
config.add_route('rdf_edit','/rdf_edit/{nodossier}/{date_inter}')
|
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_list','/rdf_list')
|
||||||
config.add_route('rdf_rapport','/rdf_rapport/{no_id}')
|
config.add_route('rdf_rapport','/rdf_rapport/{no_id}')
|
||||||
config.add_route('rdf_view','/rdf_view/{no_id}')
|
config.add_route('rdf_view','/rdf_view/{no_id}')
|
||||||
|
|||||||
@@ -193,8 +193,8 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="/rdf_view/${rapport.no_id}">${rapport.no_id}</a>
|
<a href="/rdf_view/${rapport.no_id}">${rapport.no_id}</a>
|
||||||
</td>
|
</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="rapport.date_rapport">${rapport.date_rapport.strftime('%d-%m-%Y')}</td>
|
||||||
<td tal:condition="not rapport.date_rapport"></td>
|
<td tal:condition="not rapport.date_rapport"></td>
|
||||||
<td>${rapport.C_QUALITE} ${rapport.C_NOM}</td>
|
<td>${rapport.C_QUALITE} ${rapport.C_NOM}</td>
|
||||||
<td>${rapport.NOSIN}</td>
|
<td>${rapport.NOSIN}</td>
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
<table id="users_list" class="table table-striped table-bordered">
|
<table id="users_list" class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Dossier</th>
|
<th>Rapport</th>
|
||||||
<th>Date interv.</th>
|
<th>Intervenu</th>
|
||||||
<th>Date rapport</th>
|
<th>Validé</th>
|
||||||
|
<th>Généré</th>
|
||||||
<th>Chantier</th>
|
<th>Chantier</th>
|
||||||
<th>Client</th>
|
<th>Client</th>
|
||||||
<th>No sinistre</th>
|
<th>No sinistre</th>
|
||||||
<th>Auteur</th>
|
<th>Auteur</th>
|
||||||
<th>Rapport</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
@@ -40,10 +40,11 @@
|
|||||||
{ "targets": 0,
|
{ "targets": 0,
|
||||||
"render": function (data, type, row, meta) {
|
"render": function (data, type, row, meta) {
|
||||||
// ajouter un link vers le formulaire
|
// 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 />
|
<br />
|
||||||
<div tal:condition="pt_name=='rdf_view'">
|
<div tal:condition="pt_name=='rdf_view'">
|
||||||
<p>
|
<p>
|
||||||
<a href="${request.application_url}/upload_img/${norapport}" class="btn btn-success" role="button">
|
<a href="${request.application_url}/upload_img/${norapport}" class="btn btn-primary" role="button">
|
||||||
<span class="glyphicon glyphicon-cloud-upload"></span> Ajouter une photo</a>
|
<span class="glyphicon glyphicon-picture"></span> Gérer les photos</a>
|
||||||
</p>
|
</p>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
|
|
||||||
<table class="table table-condensed ">
|
<table class="table table-condensed ">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td width="40%">
|
||||||
<label>Date du rapport :</label> ${date_rapport}
|
<label>Date du rapport :</label> ${date_rapport}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
@@ -316,8 +316,11 @@
|
|||||||
<br />${rapport.auteur_nom}
|
<br />${rapport.auteur_nom}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<label>Relu par le superviseur :</label>
|
<div tal:condition="date_relu!=''">
|
||||||
<br />Jean-Marc PENEL
|
<label>Relu par le superviseur :</label>
|
||||||
|
<br />Jean-Marc PENEL
|
||||||
|
<br />le ${date_relu}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label>Signature du client :</label>
|
<label>Signature du client :</label>
|
||||||
@@ -334,12 +337,17 @@
|
|||||||
<span class="glyphicon glyphicon-arrow-left"></span> Retour Dossier</a>
|
<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')}">
|
<a class="btn btn-primary" href="/rdf_edit/${nodossier}/${rapport.date_inter.strftime('%Y-%m-%d')}">
|
||||||
<span class="glyphicon glyphicon-pencil"></span> Modifier</a>
|
<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>
|
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||||
<a class="btn btn-default" href="/rdf_rapport/${rapport.no_id}">
|
<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-file"></span> Aperçu PDF</a>
|
<span class="glyphicon glyphicon-remove"></span> Valider</button>
|
||||||
<button class="btn btn-warning" type="submit" name="form.generate">
|
<div tal:condition="(logged_in=='MD' or logged_in=='CAO') and date_relu!=''">
|
||||||
<span class="glyphicon glyphicon-file"></span> Générer PDF</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +1,59 @@
|
|||||||
<metal:block use-macro="main_template">
|
<metal:block use-macro="main_template">
|
||||||
<div metal:fill-slot="content">
|
<div metal:fill-slot="content">
|
||||||
|
|
||||||
<div class="row">
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
<form id="upload_doc-form" action="${url}" method="post" accept-charset="utf-8" enctype="multipart/form-data"
|
<h4 class="panel-title">
|
||||||
data-fv-framework="bootstrap"
|
<span class="glyphicon glyphicon-plus"></span> AJOUTER UNE PHOTO
|
||||||
data-fv-icon-valid="glyphicon glyphicon-ok"
|
</h4>
|
||||||
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>
|
||||||
<div class="form-group">
|
<div class="panel-body">
|
||||||
<a class="btn btn-default" href="${request.route_url('rdf_view', no_id=norapport)}">
|
<div class="col-sm-6">
|
||||||
<span class="glyphicon glyphicon-arrow-left"></span> Retour au rapport</a>
|
<form id="upload_doc-form" action="${url}" method="post" accept-charset="utf-8" enctype="multipart/form-data"
|
||||||
<button id="uploadButton" class="btn btn-primary" type="submit" name="form.submitted">
|
data-fv-framework="bootstrap"
|
||||||
<i class="glyphicon glyphicon-refresh"></i> Télécharger</button>
|
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>
|
</div>
|
||||||
</form>
|
|
||||||
</div> <!-- row -->
|
|
||||||
<div class="row">
|
<div class="panel-heading">
|
||||||
<ul>
|
<h4 class="panel-title">
|
||||||
<li>Seuls les documents au format <b>PNG, JPG ou JPEG</b> seront acceptés.</li>
|
<span class="glyphicon glyphicon-arrow-up"></span> PHOTOS DEJA TELECHARGES
|
||||||
<li>La taille de chaque document ne doit <b>pas dépasser 2 Mo</b>.</li>
|
</h4>
|
||||||
</ul>
|
</div>
|
||||||
</div> <!-- row -->
|
<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">
|
<script type="text/javascript">
|
||||||
$('#uploadButton').on('click', function(){
|
$('#uploadButton').on('click', function(){
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
language: {
|
language: {
|
||||||
url: 'https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json'
|
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)
|
photos = get_photos(request, nochantier, norapport)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': u"Télécharger une photo",
|
'page_title': u"Gérer les photos",
|
||||||
'url': url,
|
'url': url,
|
||||||
'nochantier': nochantier,
|
'nochantier': nochantier,
|
||||||
'norapport': norapport,
|
'norapport': norapport,
|
||||||
@@ -514,13 +514,17 @@ def rdf_list(request):
|
|||||||
# construire la liste
|
# construire la liste
|
||||||
liste=[]
|
liste=[]
|
||||||
for item in items:
|
for item in items:
|
||||||
|
if item.date_relu :
|
||||||
|
date_relu = item.date_relu.strftime('%d-%m-%Y')
|
||||||
|
else:
|
||||||
|
date_relu = ''
|
||||||
if item.date_rapport :
|
if item.date_rapport :
|
||||||
date_rapport = item.date_rapport.strftime('%d-%m-%Y')
|
date_rapport = item.date_rapport.strftime('%d-%m-%Y')
|
||||||
else:
|
else:
|
||||||
date_rapport = ''
|
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,
|
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, item.no_id)
|
item.auteur_code)
|
||||||
liste.append(d)
|
liste.append(d)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -537,6 +541,10 @@ def rdf_view(request):
|
|||||||
# lire le rapport
|
# lire le rapport
|
||||||
rapport = get_rapport_by_no_id(request, norapport)
|
rapport = get_rapport_by_no_id(request, norapport)
|
||||||
nodossier = 'PL-' + str(rapport.nochantier)
|
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:
|
if rapport.date_rapport:
|
||||||
date_rapport = rapport.date_rapport.strftime('%d-%m-%Y')
|
date_rapport = rapport.date_rapport.strftime('%d-%m-%Y')
|
||||||
else:
|
else:
|
||||||
@@ -578,6 +586,10 @@ def rdf_view(request):
|
|||||||
request.session.flash(u"Le rapport a été génré avec succès.", 'success')
|
request.session.flash(u"Le rapport a été génré avec succès.", 'success')
|
||||||
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
|
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:
|
if 'form.delete' in request.params:
|
||||||
delete_rapport(request, norapport)
|
delete_rapport(request, norapport)
|
||||||
request.session.flash(u"Le rapporta été supprimé avec succès.", 'success')
|
request.session.flash(u"Le rapporta été supprimé avec succès.", 'success')
|
||||||
@@ -593,6 +605,7 @@ def rdf_view(request):
|
|||||||
'nochantier': rapport.nochantier,
|
'nochantier': rapport.nochantier,
|
||||||
'norapport': norapport,
|
'norapport': norapport,
|
||||||
'date_rapport': date_rapport,
|
'date_rapport': date_rapport,
|
||||||
|
'date_relu': date_relu,
|
||||||
'photos': photos,
|
'photos': photos,
|
||||||
'docs_url': request.static_url(request.registry.settings['mondumas.devfac_url']),
|
'docs_url': request.static_url(request.registry.settings['mondumas.devfac_url']),
|
||||||
}
|
}
|
||||||
@@ -624,3 +637,15 @@ def rdf_rapport(request):
|
|||||||
'photos': photos,
|
'photos': photos,
|
||||||
'docs_url': request.static_url(request.registry.settings['mondumas.devfac_url']),
|
'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