test dessin_edit
This commit is contained in:
@@ -366,20 +366,13 @@ def get_factures_en_att(request, societe):
|
|||||||
results = request.dbsession.execute(query, {'societe': societe}).fetchall()
|
results = request.dbsession.execute(query, {'societe': societe}).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def insert_dem_note(request, nodossier, type_note, logged_in):
|
def get_dem_notes(request, nodossier, noligne):
|
||||||
societe = nodossier[0:2]
|
|
||||||
nochantier = int(nodossier[3:])
|
|
||||||
# une note ou croquis
|
|
||||||
query = "INSERT INTO dem_notes (societe, nochantier, type_note, usermaj) VALUES (:societe, :nochantier, :type_note, :logged_in);"
|
|
||||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'type_note': type_note, 'logged_in': logged_in})
|
|
||||||
|
|
||||||
def get_dem_notes(request, nodossier, noligne, type):
|
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
nochantier = int(nodossier[3:])
|
nochantier = int(nodossier[3:])
|
||||||
|
|
||||||
if noligne == '0':
|
if noligne == '0':
|
||||||
query = "SELECT societe, nochantier, noligne, type_note, libelle FROM dem_notes WHERE societe = :societe AND nochantier = :nochantier AND type_note=:type ORDER BY libelle;"
|
query = "SELECT societe, nochantier, noligne, libelle FROM dem_notes WHERE societe = :societe AND nochantier = :nochantier ORDER BY libelle;"
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne, 'type': type}).fetchall()
|
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne}).fetchall()
|
||||||
else:
|
else:
|
||||||
query = "SELECT * FROM dem_notes WHERE societe = :societe AND nochantier = :nochantier AND noligne = :noligne;"
|
query = "SELECT * FROM dem_notes WHERE societe = :societe AND nochantier = :nochantier AND noligne = :noligne;"
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne}).first()
|
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne}).first()
|
||||||
@@ -388,13 +381,25 @@ def get_dem_notes(request, nodossier, noligne, type):
|
|||||||
def delete_dem_note(request, nodossier, noligne):
|
def delete_dem_note(request, nodossier, noligne):
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
nochantier = int(nodossier[3:])
|
nochantier = int(nodossier[3:])
|
||||||
# une note ou croquis
|
# une note ou dessin
|
||||||
query = "DELETE FROM dem_notes WHERE societe=:societe AND nochantier=:nochantier AND noligne=:noligne;"
|
query = "DELETE FROM dem_notes WHERE societe=:societe AND nochantier=:nochantier AND noligne=:noligne;"
|
||||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne})
|
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne})
|
||||||
|
|
||||||
def update_dem_note(request, nodossier, noligne, notes):
|
def update_dem_note(request, nodossier, noligne, notes, logged_in):
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
nochantier = int(nodossier[3:])
|
nochantier = int(nodossier[3:])
|
||||||
# une note ou croquis
|
# création ou modif ?
|
||||||
query = "UPDATE dem_notes SET notes=:notes WHERE societe=:societe AND nochantier=:nochantier AND noligne=:noligne;"
|
if noligne == '0':
|
||||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne, 'notes': notes})
|
query = "INSERT INTO dem_notes (societe, nochantier, notes, usermaj) VALUES (:societe, :nochantier, :notes, :logged_in);"
|
||||||
|
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'notes': notes, 'logged_in': logged_in})
|
||||||
|
else:
|
||||||
|
query = "UPDATE dem_notes SET notes=:notes, logged_in=:logged_in WHERE societe=:societe AND nochantier=:nochantier AND noligne=:noligne;"
|
||||||
|
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'noligne': noligne, 'notes': notes, 'logged_in': logged_in})
|
||||||
|
|
||||||
|
def get_nb_dessins(request, nodossier):
|
||||||
|
societe = nodossier[0:2]
|
||||||
|
nochantier = nodossier[3:]
|
||||||
|
|
||||||
|
query = "SELECT count(*) AS nb FROM dossier_attaches WHERE societe=:societe AND nochantier=:nochantier AND origine='FRN' AND nomfichier LIKE '%DESSIN No %';"
|
||||||
|
results = request.dbsession.execute(query, {'societe': societe, 'nochantier': nochantier}).first()
|
||||||
|
return results.nb
|
||||||
|
|||||||
@@ -33,18 +33,17 @@ def includeme(config):
|
|||||||
config.add_route('facture_select', '/facture_select/{date}')
|
config.add_route('facture_select', '/facture_select/{date}')
|
||||||
config.add_route('facture_selected', '/facture_selected/{goto}/{date}/{nofacture}')
|
config.add_route('facture_selected', '/facture_selected/{goto}/{date}/{nofacture}')
|
||||||
# dossier
|
# dossier
|
||||||
config.add_route('croquis_edit','/croquis_edit/')
|
|
||||||
config.add_route('demandes','/demandes')
|
config.add_route('demandes','/demandes')
|
||||||
config.add_route('demandes_dl','/demandes_dl/{societe}/{email_from}/{email_uid}')
|
config.add_route('demandes_dl','/demandes_dl/{societe}/{email_from}/{email_uid}')
|
||||||
config.add_route('dem_devis','/dem_devis')
|
config.add_route('dem_devis','/dem_devis')
|
||||||
config.add_route('delete_img','/delete_img/{nodossier}/{norapport}/{origine}/{nomfic}')
|
config.add_route('delete_img','/delete_img/{nodossier}/{norapport}/{origine}/{nomfic}')
|
||||||
config.add_route('dern_suivis','/dern_suivis')
|
config.add_route('dern_suivis','/dern_suivis')
|
||||||
|
config.add_route('dessin_edit','/dessin_edit/{nodossier}/{noligne}')
|
||||||
config.add_route('dossier_edit', '/dossier_edit/{nodossier}')
|
config.add_route('dossier_edit', '/dossier_edit/{nodossier}')
|
||||||
config.add_route('dossier_lookup', '/dossier_lookup')
|
config.add_route('dossier_lookup', '/dossier_lookup')
|
||||||
config.add_route('dossier_select', '/dossier_select/{date}')
|
config.add_route('dossier_select', '/dossier_select/{date}')
|
||||||
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('note_add','/note_add/{nodossier}')
|
|
||||||
config.add_route('note_edit','/note_edit/{nodossier}/{noligne}')
|
config.add_route('note_edit','/note_edit/{nodossier}/{noligne}')
|
||||||
config.add_route('rdf_bill','/rdf_bill/{no_id}')
|
config.add_route('rdf_bill','/rdf_bill/{no_id}')
|
||||||
config.add_route('rdf_client','/rdf_client/{no_id}')
|
config.add_route('rdf_client','/rdf_client/{no_id}')
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
<metal:block use-macro="main_template">
|
|
||||||
<div metal:fill-slot="content">
|
|
||||||
|
|
||||||
<div style="row">
|
|
||||||
<div id="dessin"></div>
|
|
||||||
</div> <!-- row -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Drawingboard -->
|
|
||||||
<link href="${request.static_url('mondumas:static/dist/drawingboard/drawingboard.min.css')}" rel="stylesheet" media="all">
|
|
||||||
<script src="${request.static_url('mondumas:static/dist/drawingboard/drawingboard.min.js')}"></script>
|
|
||||||
<script>
|
|
||||||
var simpleBoard = new DrawingBoard.Board('dessin', {
|
|
||||||
background: 'none',
|
|
||||||
size: 10,
|
|
||||||
controls: [
|
|
||||||
'Color',
|
|
||||||
{ Size: { type: 'dropdown' } },
|
|
||||||
{ Navigation: { } },
|
|
||||||
],
|
|
||||||
size: 1,
|
|
||||||
webStorage: 'session',
|
|
||||||
enlargeYourContainer: true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div><!-- content -->
|
|
||||||
</metal:block>
|
|
||||||
60
mondumas/templates/dossier/dessin_edit.pt
Normal file
60
mondumas/templates/dossier/dessin_edit.pt
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<metal:block use-macro="main_template">
|
||||||
|
<div metal:fill-slot="content">
|
||||||
|
|
||||||
|
<div class="alert alert-danger" tal:condition="message" tal:content="message" />
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<form id="dessin_edit-form" action="${url}" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<a href="${request.application_url}/dossier_view/${nodossier}" class="btn btn-default" role="button">
|
||||||
|
<span class="glyphicon glyphicon-chevron-left"></span> Annuler</a>
|
||||||
|
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||||
|
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||||
|
</div>
|
||||||
|
<!-- this will be the input used to pass the drawingboard content to the server -->
|
||||||
|
<input type="hidden" name="image" value="">
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div> <!-- row -->
|
||||||
|
<div style="row">
|
||||||
|
<div id="dessin"></div>
|
||||||
|
</div> <!-- row -->
|
||||||
|
|
||||||
|
<!-- Drawingboard -->
|
||||||
|
<link href="${request.static_url('mondumas:static/dist/drawingboard/drawingboard.min.css')}" rel="stylesheet" media="all">
|
||||||
|
<script src="${request.static_url('mondumas:static/dist/drawingboard/drawingboard.min.js')}"></script>
|
||||||
|
<script>
|
||||||
|
var simpleBoard = new DrawingBoard.Board('dessin', {
|
||||||
|
background: 'none',
|
||||||
|
size: 10,
|
||||||
|
controls: [
|
||||||
|
'Color',
|
||||||
|
{ Size: { type: 'dropdown' } },
|
||||||
|
{ Navigation: { } },
|
||||||
|
],
|
||||||
|
size: 1,
|
||||||
|
webStorage: 'session',
|
||||||
|
enlargeYourContainer: true
|
||||||
|
});
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#dessin_edit-form').on('submit', function(e) {
|
||||||
|
//get drawingboard content
|
||||||
|
var img = simpleBoard.getImg();
|
||||||
|
|
||||||
|
//we keep drawingboard content only if it's not the 'blank canvas'
|
||||||
|
var imgInput = (simpleBoard.blankCanvas == img) ? '' : img;
|
||||||
|
// alert("imgInput : " + imgInput);
|
||||||
|
|
||||||
|
//put the drawingboard content in the form field to send it to the server
|
||||||
|
$(this).find('input[name=image]').val( imgInput );
|
||||||
|
|
||||||
|
//we can also assume that everything goes well server-side
|
||||||
|
//and directly clear webstorage here so that the drawing isn't shown again after form submission
|
||||||
|
//but the best would be to do when the server answers that everything went well
|
||||||
|
simpleBoard.clearWebStorage();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</div><!-- content -->
|
||||||
|
</metal:block>
|
||||||
@@ -283,38 +283,24 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h3 class="text-center">NOTES et CROQUIS</h3>
|
<h3 class="text-center">NOTES et DESSIN</h3>
|
||||||
|
<p>
|
||||||
|
<a href="${request.application_url}/note_edit/${nodossier}/0" class="btn btn-success" role="button">
|
||||||
|
<span class="glyphicon glyphicon-text-size"></span> Ajouter une NOTE</a>
|
||||||
|
<a href="${request.application_url}/dessin_edit/${nodossier}/0" class="btn btn-success" role="button">
|
||||||
|
<span class="glyphicon glyphicon-picture"></span> Ajouter dessin</a>
|
||||||
|
</p>
|
||||||
<br />
|
<br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- bouton AJOUT NOTE-->
|
|
||||||
<div class="text-center col-sm-3">
|
|
||||||
<a href="${request.application_url}/note_add/${nodossier}">
|
|
||||||
<span class="glyphicon glyphicon-plus logo-success"></span>
|
|
||||||
<h4>NOTE</h4></a>
|
|
||||||
</div>
|
|
||||||
<!-- Listes des Notes -->
|
<!-- Listes des Notes -->
|
||||||
<div class="text-center" tal:repeat="item dem_notes">
|
<div class="text-center" tal:repeat="item dem_notes">
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<a href="${request.application_url}/note_edit/${nodossier}/${item.noligne}" tal:condition="item.type_note=='NOTE'">
|
<a href="${request.application_url}/note_edit/${nodossier}/${item.noligne}">
|
||||||
<span class="glyphicon glyphicon-text-size logo-primary"></span>
|
<span class="glyphicon glyphicon-text-size logo-primary"></span>
|
||||||
<h4>${item.libelle}</h4></a>
|
<h4>${item.libelle}</h4></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="text-center col-sm-3">
|
|
||||||
<a href="${request.application_url}/croquis_edit/">
|
|
||||||
<span class="glyphicon glyphicon-plus logo-success"></span>
|
|
||||||
<h4>CROQUIS</h4></a>
|
|
||||||
</div>
|
|
||||||
<div class="text-center" tal:repeat="item dem_croquis">
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<a href="${request.application_url}/croquis_edit/" tal:condition="item.type_note=='CROQUIS'">
|
|
||||||
<span class="glyphicon glyphicon-picture logo-primary"></span>
|
|
||||||
<h4>${item.libelle}</h4></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- PANEL RDF -->
|
<!-- PANEL RDF -->
|
||||||
<div id="tab_rdf" class="tab-pane fade">
|
<div id="tab_rdf" class="tab-pane fade">
|
||||||
@@ -394,34 +380,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Modal : add NOTES et CROQUIS -->
|
|
||||||
<div class="modal fade" id="addNote" role="dialog" aria-labelledby="addNoteLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
||||||
<h4 class="modal-title">Ajouter une note ou un croquis</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<!-- The form is placed inside the body of modal -->
|
|
||||||
<form id="add_justif-form" class="form-horizontal" action="${url}" method="post">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label col-sm-6">Voulez-vous ajouter</label>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<label class="radio-inline"><input type="radio" name="type_note" value="NOTE" checked>une note</label>
|
|
||||||
<label class="radio-inline"><input type="radio" name="type_note" value="CROQUIS">un croquis</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
|
|
||||||
<button type="submit" class="btn btn-warning" name="form.addNote">Ajouter</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|||||||
@@ -5,13 +5,6 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form id="text_edit-form" action="${url}" method="post">
|
<form id="text_edit-form" action="${url}" method="post">
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="control-label" for="text-text">Tapez ou dictez le texte :</label>
|
|
||||||
<textarea class="form-control monospace-font" rows="30" cols="40" id="notes" name="notes">${note.notes}</textarea>
|
|
||||||
</div>
|
|
||||||
<p>Modifié le : ${note.modif_le.strftime('%d-%m-%Y')} par ${note.usermaj}
|
|
||||||
</p>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<a href="${request.application_url}/dossier_view/${nodossier}" class="btn btn-default" role="button">
|
<a href="${request.application_url}/dossier_view/${nodossier}" class="btn btn-default" role="button">
|
||||||
<span class="glyphicon glyphicon-chevron-left"></span> Annuler</a>
|
<span class="glyphicon glyphicon-chevron-left"></span> Annuler</a>
|
||||||
@@ -20,10 +13,16 @@
|
|||||||
<button class="btn btn-warning" type="submit" name="form.deleted">
|
<button class="btn btn-warning" type="submit" name="form.deleted">
|
||||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label" for="text-text">Tapez ou dictez le texte :</label>
|
||||||
|
<textarea class="form-control monospace-font" rows="30" cols="40" id="notes" name="notes">${note.notes}</textarea>
|
||||||
|
</div>
|
||||||
|
<p>Modifié le : ${note.modif_le.strftime('%d-%m-%Y')} par ${note.usermaj}
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
</div> <!-- row -->
|
</div> <!-- row -->
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|||||||
@@ -129,9 +129,7 @@ def dossier_view(request):
|
|||||||
status = get_status_by_id(request, '')
|
status = get_status_by_id(request, '')
|
||||||
motifs = get_motifs(request)
|
motifs = get_motifs(request)
|
||||||
# lire les notes du dossier
|
# lire les notes du dossier
|
||||||
dem_notes = get_dem_notes(request, nodossier, '0', 'NOTE')
|
dem_notes = get_dem_notes(request, nodossier, '0')
|
||||||
# lire les croquis du dossier
|
|
||||||
dem_croquis = get_dem_notes(request, nodossier, '0', 'CROQUIS')
|
|
||||||
|
|
||||||
if 'form.close' in request.params:
|
if 'form.close' in request.params:
|
||||||
status = request.params["status"]
|
status = request.params["status"]
|
||||||
@@ -167,7 +165,6 @@ def dossier_view(request):
|
|||||||
'motifs': motifs,
|
'motifs': motifs,
|
||||||
'motif': '',
|
'motif': '',
|
||||||
'dem_notes': dem_notes,
|
'dem_notes': dem_notes,
|
||||||
'dem_croquis': dem_croquis,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='dossier_selected', permission='view')
|
@view_config(route_name='dossier_selected', permission='view')
|
||||||
@@ -1623,28 +1620,29 @@ def dem_devis(request):
|
|||||||
'order_option': order_option,
|
'order_option': order_option,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='note_add', permission='view')
|
|
||||||
def note_add(request):
|
|
||||||
logged_in = request.authenticated_userid.upper()
|
|
||||||
nodossier = request.matchdict['nodossier']
|
|
||||||
insert_dem_note(request, nodossier, 'NOTE', logged_in)
|
|
||||||
|
|
||||||
return HTTPFound(request.route_url('dossier_view', nodossier=nodossier))
|
|
||||||
|
|
||||||
@view_config(route_name='note_edit', renderer='../templates/dossier/note_edit.pt', permission='view')
|
@view_config(route_name='note_edit', renderer='../templates/dossier/note_edit.pt', permission='view')
|
||||||
def note_edit(request):
|
def note_edit(request):
|
||||||
|
logged_in = request.authenticated_userid.upper()
|
||||||
nodossier = request.matchdict['nodossier']
|
nodossier = request.matchdict['nodossier']
|
||||||
noligne = request.matchdict['noligne']
|
noligne = request.matchdict['noligne']
|
||||||
url = request.route_url('note_edit', nodossier=nodossier, noligne=noligne)
|
url = request.route_url('note_edit', nodossier=nodossier, noligne=noligne)
|
||||||
|
|
||||||
message = ""
|
message = ""
|
||||||
note = get_dem_notes(request, nodossier, noligne, 'NOTE')
|
if noligne == '0':
|
||||||
|
page_title = nodossier + ' : Nouvelle note'
|
||||||
|
note = {}
|
||||||
|
note['notes'] = ''
|
||||||
|
note['usermaj'] = logged_in
|
||||||
|
note['modif_le'] = date.today()
|
||||||
|
else:
|
||||||
|
note = get_dem_notes(request, nodossier, noligne)
|
||||||
|
page_title = nodossier + " : " + note.libelle
|
||||||
|
|
||||||
if 'form.submitted' in request.params:
|
if 'form.submitted' in request.params:
|
||||||
notes = request.params["notes"]
|
notes = request.params["notes"]
|
||||||
|
|
||||||
update_dem_note(request, nodossier, noligne, notes)
|
update_dem_note(request, nodossier, noligne, notes, logged_in)
|
||||||
request.session.flash("'%s' a été modifiée avec succès." % note.libelle, 'success')
|
request.session.flash("La note a été modifiée 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.deleted' in request.params:
|
if 'form.deleted' in request.params:
|
||||||
@@ -1653,18 +1651,61 @@ def note_edit(request):
|
|||||||
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
|
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': note.libelle,
|
'page_title': page_title,
|
||||||
'url': url,
|
'url': url,
|
||||||
'message': message,
|
'message': message,
|
||||||
'nodossier': nodossier,
|
'nodossier': nodossier,
|
||||||
'note': note,
|
'note': note,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='croquis_edit', renderer='../templates/dossier/croquis_edit.pt', permission='view')
|
@view_config(route_name='dessin_edit', renderer='../templates/dossier/dessin_edit.pt', permission='view')
|
||||||
def croquis_edit(request):
|
def dessin_edit(request):
|
||||||
|
logged_in = request.authenticated_userid.upper()
|
||||||
|
nodossier = request.matchdict['nodossier']
|
||||||
|
noligne = request.matchdict['noligne']
|
||||||
|
url = request.route_url('dessin_edit', nodossier=nodossier, noligne=noligne)
|
||||||
|
societe = nodossier[0:2]
|
||||||
|
nochantier = nodossier[3:]
|
||||||
|
|
||||||
|
message = ""
|
||||||
|
if noligne == '0':
|
||||||
|
page_title = nodossier + ' : Nouveau dessin'
|
||||||
|
else:
|
||||||
|
page_title = nodossier + " : "
|
||||||
|
|
||||||
|
if 'form.submitted' in request.params:
|
||||||
|
# get the base64-encoded-canvas image
|
||||||
|
img_data = request.params["image"]
|
||||||
|
img_data = img_data.replace('data:image/png;base64', '')
|
||||||
|
img_data = img_data.replace(' ', '+')
|
||||||
|
# convertir image de string en bytes
|
||||||
|
img_bytes = img_data.encode('utf-8')
|
||||||
|
decoded_image = base64.decodebytes(img_bytes)
|
||||||
|
|
||||||
|
# lire le nombre de dessins déjà créés
|
||||||
|
nb_dessins = get_nb_dessins(request, nodossier)
|
||||||
|
# fabriquer le nom du dessin
|
||||||
|
filename = '%s-DD%s-%s' % (societe, nochantier, 'DESSIN No ' + str(nb_dessins + 1) + ".png")
|
||||||
|
path = '%s/%s/%s' % (request.registry.settings['mondumas.devfac_dir'], societe, nochantier)
|
||||||
|
# créer le répertoire du chantier
|
||||||
|
os.makedirs(path, exist_ok=True)
|
||||||
|
|
||||||
|
filepath = os.path.join('%s/%s' % (path, filename))
|
||||||
|
# ecrire l'image dans un fichier PNG
|
||||||
|
f = open(filepath, "wb")
|
||||||
|
f.write(decoded_image)
|
||||||
|
f.close
|
||||||
|
|
||||||
|
filesize = round(os.path.getsize(filepath) / 1024)
|
||||||
|
insert_dossier_attaches(request, '%s-%s' % (societe, nochantier), 0, 'FRN', filename, '%s Ko' % str(filesize), logged_in)
|
||||||
|
|
||||||
|
request.session.flash('%s est enregistré dans les DOC. TECHNIQUES.' % filename, 'success')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': 'NOUVEAU CROQUIS',
|
'page_title': page_title,
|
||||||
|
'url': url,
|
||||||
|
'message': message,
|
||||||
|
'nodossier': nodossier,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='dern_suivis', renderer='../templates/dossier/dern_suivis.pt', permission='view')
|
@view_config(route_name='dern_suivis', renderer='../templates/dossier/dern_suivis.pt', permission='view')
|
||||||
|
|||||||
Reference in New Issue
Block a user