finaliser tests cabinet + expet
This commit is contained in:
34
.vscode/launch.json
vendored
Normal file
34
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"name": "Pserve",
|
||||
"python": "/Users/phuoc/AppData/Local/Programs/Python/Python37",
|
||||
"program": "/pyramid10/Scripts/pserve",
|
||||
"args": [
|
||||
"-v",
|
||||
"development.ini"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"debugOptions": [
|
||||
"RedirectOutput",
|
||||
"WaitOnAbnormalExit",
|
||||
"WaitOnNormalExit"
|
||||
],
|
||||
"python.unitTest.promptToConfigure":false,
|
||||
"files.exclude": {
|
||||
"**/.git": true,
|
||||
"**/.svn": true,
|
||||
"**/.hg": true,
|
||||
"**/.DS_Store": true,
|
||||
".idea": true,
|
||||
"**/*.pyc": true,
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.pythonPath": "C:\\pyramid10\\Scripts\\python.exe"
|
||||
}
|
||||
@@ -57,11 +57,11 @@ def get_cabinets_by_id(request, code):
|
||||
def get_experts_by_id(request, code_cab, code_exp):
|
||||
# lire les experts du cabinet
|
||||
if code_exp == '0':
|
||||
query = """SELECT * FROM P_EXPERTS WHERE code_cab=:code_cab AND en_activite <> 0 ORDER BY nom;"""
|
||||
query = """SELECT * FROM P_EXPERTS WHERE code_cab=:code_cab ORDER BY nom;"""
|
||||
results = request.dbsession.execute(query, {'code_cab': code_cab}).fetchall()
|
||||
else:
|
||||
query = """SELECT * FROM P_EXPERTS WHERE code_cab=:code_cab AND code_exp=:code_exp;"""
|
||||
results = request.dbsession.execute(query, {'code_cab': code_cab}, {'code_exp': code_exp}).first()
|
||||
results = request.dbsession.execute(query, {'code_cab': code_cab, 'code_exp': code_exp}).first()
|
||||
return results
|
||||
|
||||
def get_rdf_causes_by_id(request, code):
|
||||
@@ -162,3 +162,50 @@ def delete_article(request, ref):
|
||||
query = "DELETE FROM articles WHERE ref = :ref ;"
|
||||
execute_query(request, query, {'ref': ref})
|
||||
|
||||
def update_cabinet(request, code, new_values):
|
||||
# formater les champs
|
||||
s = ''
|
||||
for param in new_values.keys():
|
||||
if s:
|
||||
s += ",%s=:%s" % (param, param)
|
||||
else:
|
||||
s = "%s=:%s" % (param, param)
|
||||
|
||||
if code == '0':
|
||||
query = "CALL spINS_P_CABINET(:nom);"
|
||||
results = request.dbsession.execute(query, {'nom': new_values['NOM']}).first()
|
||||
# recupère lenouveau code créé
|
||||
code = results.newligne
|
||||
|
||||
new_values['code'] = code
|
||||
query = "UPDATE p_cabinet SET %s WHERE code = :code;" % s
|
||||
execute_query(request, query, new_values)
|
||||
|
||||
def delete_cabinet(request, code):
|
||||
query = "DELETE FROM p_cabinet WHERE code = :code ;"
|
||||
execute_query(request, query, {'code': code})
|
||||
|
||||
def update_expert(request, code_cab, code_exp, new_values):
|
||||
# formater les champs
|
||||
s = ''
|
||||
for param in new_values.keys():
|
||||
if s:
|
||||
s += ",%s=:%s" % (param, param)
|
||||
else:
|
||||
s = "%s=:%s" % (param, param)
|
||||
|
||||
if code_exp == '0':
|
||||
query = "CALL spINS_P_EXPERT(:code_cab, :nom);"
|
||||
results = request.dbsession.execute(query, {'code_cab': code_cab, 'nom': new_values['NOM']}).first()
|
||||
# recupère lenouveau code créé
|
||||
code_exp = results.newligne
|
||||
|
||||
new_values['code_cab'] = code_cab
|
||||
new_values['code_exp'] = code_exp
|
||||
query = "UPDATE p_experts SET %s WHERE code_cab = :code_cab AND code_exp = :code_exp;" % s
|
||||
execute_query(request, query, new_values)
|
||||
|
||||
def delete_expert(request, code_cab, code_exp):
|
||||
query = "DELETE FROM p_experts WHERE code_cab = :code_cab AND code_exp = :code_exp;"
|
||||
execute_query(request, query, {'code_cab': code_cab, 'code_exp': code_exp})
|
||||
|
||||
|
||||
@@ -3,152 +3,141 @@
|
||||
|
||||
<div tal:condition="message" tal:content="message" class="alert alert-danger" />
|
||||
<br />
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#tab_cabinet"><b>CABINET</b></a></li>
|
||||
<li><a data-toggle="tab" href="#tab_experts"><b>EXPERTS</b></a></li>
|
||||
</ul>
|
||||
<!-- PANEL SUIVI -->
|
||||
<div class="tab-content">
|
||||
<div id="tab_cabinet" class="tab-pane fade in active">
|
||||
<h3>CABINET</h3>
|
||||
<form id="cabinet-form" class="form-horizontal" action="${url}" method="post"
|
||||
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">
|
||||
|
||||
<h3>CABINET</h3>
|
||||
<form id="rdf_cabinet-form" class="form-horizontal" action="${url}" method="post"
|
||||
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 class="control-label col-xs-3" for="CODE">Code</label>
|
||||
<div class="col-xs-9">
|
||||
<input class="form-control" type="text" id="CODE" name="CODE" value="${cabinet.CODE}" readonly />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-3" for="code">Code</label>
|
||||
<div class="col-xs-9">
|
||||
<p class="form-control-static">${code}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-3" for="NOM">Nom</label>
|
||||
<div class="col-xs-9">
|
||||
<input class="form-control" type="text" id="NOM" name="NOM" value="${cabinet.NOM}"
|
||||
placeholder="30 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="Un libellé est obligatoire"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="30"
|
||||
data-fv-stringlength-message="30 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-3" for="NOM">Nom</label>
|
||||
<div class="col-xs-9">
|
||||
<input class="form-control" type="text" id="NOM" name="NOM" value="${cabinet.NOM}"
|
||||
placeholder="30 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="Le nom est obligatoire"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="30"
|
||||
data-fv-stringlength-message="30 caractères maximum" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="ADRESSE">Adresse</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="ADRESSE" name="ADRESSE" value="${cabinet.ADRESSE}"
|
||||
placeholder="40 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="40"
|
||||
data-fv-stringlength-message="40 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="ADRESSE">Adresse</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="ADRESSE" name="ADRESSE" value="${cabinet.ADRESSE}"
|
||||
placeholder="40 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="40"
|
||||
data-fv-stringlength-message="40 caractères maximum" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="ADRESSE2">Adresse 2</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="ADRESSE2" name="ADRESSE2" value="${cabinet.ADRESSE2}"
|
||||
placeholder="40 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="40"
|
||||
data-fv-stringlength-message="40 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="ADRESSE2">Adresse 2</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="ADRESSE2" name="ADRESSE2" value="${cabinet.ADRESSE2}"
|
||||
placeholder="40 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="40"
|
||||
data-fv-stringlength-message="40 caractères maximum" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="code_postal">Code postal - Ville</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="code_postal" name="code_postal" value="${code_postal}"
|
||||
placeholder="5 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="Le code postal est obligatoire" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="code_postal">Code postal - Ville</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="code_postal" name="code_postal" value="${code_postal}"
|
||||
placeholder="5 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="Le code postal est obligatoire" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TEL1">Télphone 1</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TEL1" value="${cabinet.TEL1}"
|
||||
placeholder="14 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="14"
|
||||
data-fv-stringlength-message="14 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TEL1">Télphone 1</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TEL1" value="${cabinet.TEL1}"
|
||||
placeholder="14 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="14"
|
||||
data-fv-stringlength-message="14 caractères maximum" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TEL2">Télphone 2</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TEL2" value="${cabinet.TEL2}"
|
||||
placeholder="14 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="14"
|
||||
data-fv-stringlength-message="14 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TEL2">Télphone 2</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TEL2" value="${cabinet.TEL2}"
|
||||
placeholder="14 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="14"
|
||||
data-fv-stringlength-message="14 caractères maximum" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TELP">Télphone portable</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TELP" value="${cabinet.TELP}"
|
||||
placeholder="14 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="14"
|
||||
data-fv-stringlength-message="14 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TELP">Télphone portable</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TELP" value="${cabinet.TELP}"
|
||||
placeholder="14 caractères maximum"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="14"
|
||||
data-fv-stringlength-message="14 caractères maximum" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-9 checkbox">
|
||||
<label><input type="checkbox" name="afficher" value="cabinet.afficher"
|
||||
tal:attributes="checked cabinet.afficher != 0 and 'checked' or None">La fiche est active
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-9 checkbox">
|
||||
<label><input type="checkbox" name="afficher" value="cabinet.afficher"
|
||||
tal:attributes="checked cabinet.afficher != 0 and 'checked' or None">La fiche est active
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-3">Dern. modif le</label>
|
||||
<div class="col-xs-9">
|
||||
<p class="form-control-static">${cabinet.modif_le.strftime('%d-%m-%Y %H:%M')}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-offset-3 col-xs-9">
|
||||
<a class="btn btn-default" href="/cabinets">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<button class="btn btn-danger" type="submit" name="form.deleted" tal:condition="cabinet.CODE != '0'">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- PANEL EXPERTS -->
|
||||
<div id="tab_experts" class="tab-pane fade">
|
||||
<h3>EXPERTS</h3>
|
||||
<p>
|
||||
<a class="btn btn-success" role="button" href="/expert_edit/${cabinet.CODE}/0">
|
||||
<span class="glyphicon glyphicon-plus"></span> Nouvel expert</a>
|
||||
</p>
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<th>Code</th>
|
||||
<th>Nom expert</th>
|
||||
<th>Tél 1</th>
|
||||
<th>Tél 2</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
<tr tal:repeat="expert experts">
|
||||
<td>${expert.CODE_EXP}</td>
|
||||
<td>
|
||||
<a href="/expert_edit/${expert.CODE_CAB}/${expert.CODE_EXP}">${expert.NOM}</a>
|
||||
</td>
|
||||
<td>${expert.TEL1}</td>
|
||||
<td>${expert.TEL2}</td>
|
||||
<td>${expert.email}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-3">Dern. modif le</label>
|
||||
<div class="col-xs-9">
|
||||
<p class="form-control-static">${cabinet.modif_le.strftime('%d-%m-%Y %H:%M')}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-offset-3 col-xs-9">
|
||||
<a class="btn btn-default" href="/cabinets">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted" tal:condition="code != '1'">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<button class="btn btn-danger" type="submit" name="form.deleted" tal:condition="code != '1'">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br />
|
||||
<h3>EXPERTS</h3>
|
||||
<p>
|
||||
<a class="btn btn-success" role="button" href="/expert_edit/${code}/0" tal:condition="code != '1'">
|
||||
<span class="glyphicon glyphicon-plus"></span> Nouvel expert</a>
|
||||
</p>
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<th>Code</th>
|
||||
<th>Nom expert</th>
|
||||
<th>Tél 1</th>
|
||||
<th>Tél 2</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
<tr tal:repeat="expert experts">
|
||||
<td tal:condition="expert.en_activite==0" class="bg-danger">${expert.CODE_EXP}</td>
|
||||
<td tal:condition="expert.en_activite!=0">${expert.CODE_EXP}</td>
|
||||
<td>
|
||||
<a href="/expert_edit/${expert.CODE_CAB}/${expert.CODE_EXP}">${expert.NOM}</a>
|
||||
</td>
|
||||
<td>${expert.TEL1}</td>
|
||||
<td>${expert.TEL2}</td>
|
||||
<td>${expert.email}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
@@ -157,7 +146,7 @@
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#rdf_cabinet-form').formValidation();
|
||||
$('#cabinet-form').formValidation();
|
||||
$('form input').on('keypress', function(e) {
|
||||
return e.which !== 13;
|
||||
});
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
data-fv-icon-validating="glyphicon glyphicon-refresh">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-3" for="CODE">Code</label>
|
||||
<label class="control-label col-xs-3" for="code_exp">Code</label>
|
||||
<div class="col-xs-9">
|
||||
<input class="form-control" type="text" id="CODE" name="CODE" value="${expert.CODE}" readonly />
|
||||
<p class="form-control-static">${code_exp}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -21,14 +21,14 @@
|
||||
<input class="form-control" type="text" id="NOM" name="NOM" value="${expert.NOM}"
|
||||
placeholder="30 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="Un libellé est obligatoire"
|
||||
data-fv-notempty-message="Le nom est obligatoire"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="30"
|
||||
data-fv-stringlength-message="30 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-3 control-label" for="TEL1">Télphone 1</label>
|
||||
<label class="col-xs-3 control-label" for="TEL1">Télphone</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" name="TEL1" value="${expert.TEL1}"
|
||||
placeholder="14 caractères maximum"
|
||||
@@ -58,7 +58,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-xs-9 checkbox">
|
||||
<label><input type="checkbox" name="afficher" value="expert.en_activite"
|
||||
<label><input type="checkbox" name="en_activite" value="expert.en_activite"
|
||||
tal:attributes="checked expert.en_activite != 0 and 'checked' or None">La fiche est active
|
||||
</label>
|
||||
</div>
|
||||
@@ -72,12 +72,12 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-offset-3 col-xs-9">
|
||||
<a class="btn btn-default" href="/cabinets">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<button class="btn btn-danger" type="submit" name="form.deleted" tal:condition="expert.CODE != '0'">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
<a class="btn btn-default" href="/cabinet_edit/${expert.CODE_CAB}">
|
||||
<span class="glyphicon glyphicon-arrow-left"></span> Annuler</a>
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted" tal:condition="code_exp != '1'">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<button class="btn btn-danger" type="submit" name="form.deleted" tal:condition="code_exp != '1'">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -276,7 +276,6 @@ def ajax_codepostal(request):
|
||||
|
||||
# lire les codes postaux commencant par
|
||||
items = get_codespostaux(request, recherche)
|
||||
# import pdb;pdb.set_trace()
|
||||
liste=[]
|
||||
for row in items:
|
||||
d = row.code_postal + " - " + row.libelle
|
||||
|
||||
@@ -244,7 +244,6 @@ def dossier_edit(request):
|
||||
# controle saisie code postal
|
||||
code_postal = request.params['code_postal']
|
||||
cp = code_postal.split(' - ')
|
||||
cp = code_postal.split(' - ')
|
||||
if len(cp) < 2:
|
||||
message = 'Code postal invalide. Veuillez sélectionner un parmi la liste.'
|
||||
else:
|
||||
|
||||
@@ -552,6 +552,13 @@ def cabinets(request):
|
||||
@view_config(route_name='cabinet_edit', renderer='../templates/parametres/cabinet_edit.pt', permission='view')
|
||||
def cabinet_edit(request):
|
||||
|
||||
logged_in = request.authenticated_userid
|
||||
# lire la fiche de l'utilisateur
|
||||
member = get_member_by_id(request, logged_in)
|
||||
access = member.access
|
||||
if access < 5:
|
||||
request.session.flash(u"Vous n'êtes pas autorisé à modifier les cabinets", 'danger')
|
||||
return HTTPFound(location=request.route_url('cabinets'))
|
||||
|
||||
code = request.matchdict['code']
|
||||
url = request.route_url("cabinet_edit", code=code)
|
||||
@@ -559,18 +566,18 @@ def cabinet_edit(request):
|
||||
message = ''
|
||||
if code == '0':
|
||||
# nouveau
|
||||
cabinet = {}
|
||||
cabinet = {}
|
||||
cabinet['NOM'] = ''
|
||||
cabinet['TEL1'] = ''
|
||||
cabinet['TEL2'] = ''
|
||||
cabinet['TELP'] = ''
|
||||
cabinet['ADR'] = ''
|
||||
cabinet['ADR2'] = ''
|
||||
cabinet['TELP'] = ''
|
||||
cabinet['ADRESSE'] = ''
|
||||
cabinet['ADRESSE2'] = ''
|
||||
cabinet['VILLE'] = ''
|
||||
cabinet['VILLE'] = ''
|
||||
cabinet['afficher'] = 1
|
||||
cabinet['modif_le'] = datetime.now()
|
||||
page_title= 'Nouveau cabinet'
|
||||
code_postal = '69001 - LYON'
|
||||
experts = []
|
||||
else:
|
||||
# lire cabinets
|
||||
@@ -583,12 +590,31 @@ def cabinet_edit(request):
|
||||
code_postal = '%s - %s' % (cabinet.CP, cabinet.VILLE)
|
||||
experts = get_experts_by_id(request, cabinet.CODE, '0')
|
||||
|
||||
if 'form.submitted' in request.params:
|
||||
code = request.params['code']
|
||||
if 'form.submitted' in request.params:
|
||||
new_values = {}
|
||||
for param, db_value in cabinet.items():
|
||||
if param in request.params and request.params[param] != db_value:
|
||||
new_values[param] = request.params[param]
|
||||
|
||||
# controle saisie code postal
|
||||
code_postal = request.params['code_postal']
|
||||
cp = code_postal.split(' - ')
|
||||
if len(cp) < 2:
|
||||
message = 'Code postal invalide. Veuillez sélectionner un parmi la liste.'
|
||||
else:
|
||||
new_values['CP'] = cp[0]
|
||||
new_values['VILLE'] = cp[1]
|
||||
|
||||
# afficher coché ?
|
||||
if 'afficher' in request.params:
|
||||
new_values['afficher'] = 1
|
||||
else:
|
||||
new_values['afficher'] = 0
|
||||
|
||||
if new_values:
|
||||
update_cabinet(request, code, new_values)
|
||||
request.session.flash(u"Le cabinet a été mis à jour avec succès.", 'success')
|
||||
return HTTPFound(location=request.route_url('cabinets'))
|
||||
|
||||
update_cabinet(request, code, libelle)
|
||||
request.session.flash(u"Le cabinet a été mis à jour avec succès.", 'success')
|
||||
|
||||
|
||||
if 'form.deleted' in request.params:
|
||||
@@ -599,6 +625,7 @@ def cabinet_edit(request):
|
||||
return {
|
||||
'page_title': page_title,
|
||||
'url': url,
|
||||
'cabinet': cabinet,
|
||||
'code': code,
|
||||
'experts': experts,
|
||||
'code_postal': code_postal,
|
||||
@@ -608,6 +635,13 @@ def cabinet_edit(request):
|
||||
@view_config(route_name='expert_edit', renderer='../templates/parametres/expert_edit.pt', permission='view')
|
||||
def expert_edit(request):
|
||||
|
||||
logged_in = request.authenticated_userid
|
||||
# lire la fiche de l'utilisateur
|
||||
member = get_member_by_id(request, logged_in)
|
||||
access = member.access
|
||||
if access < 5:
|
||||
request.session.flash(u"Vous n'êtes pas autorisé à modifier les experts", 'danger')
|
||||
return HTTPFound(location=request.route_url('cabinets'))
|
||||
|
||||
code_cab = request.matchdict['code_cab']
|
||||
code_exp = request.matchdict['code_exp']
|
||||
@@ -616,47 +650,50 @@ def expert_edit(request):
|
||||
message = ''
|
||||
if code_exp == '0':
|
||||
# nouveau
|
||||
expert = {}
|
||||
expert = {}
|
||||
expert['CODE_CAB'] = code_cab
|
||||
expert['CODE_EXP'] = code_exp
|
||||
expert['NOM'] = ''
|
||||
expert['TEL1'] = ''
|
||||
expert['TEL2'] = ''
|
||||
expert['TELP'] = ''
|
||||
expert['ADR'] = ''
|
||||
expert['ADR2'] = ''
|
||||
expert['CP'] = ''
|
||||
expert['VILLE'] = ''
|
||||
expert['TEL2'] = ''
|
||||
expert['email'] = ''
|
||||
expert['en_activite'] = 1
|
||||
expert['modif_le'] = datetime.now()
|
||||
page_title= 'Nouveau expert'
|
||||
else:
|
||||
# lire experts
|
||||
# lire experts
|
||||
expert = get_experts_by_id(request, code_cab, code_exp)
|
||||
if not expert:
|
||||
request.session.flash(u"expert non trouvé : %s" % code, 'warning')
|
||||
if not expert:
|
||||
request.session.flash(u"expert non trouvé : %s" % code_exp, 'warning')
|
||||
return HTTPFound(location=request.route_url("cabinet_edit", code=code_cab))
|
||||
|
||||
page_title= "Modification de %s" % (expert.NOM)
|
||||
code_postal = '%s - %s' % (expert.CP, expert.VILLE)
|
||||
page_title= "Modification de %s" % (expert.NOM)
|
||||
|
||||
if 'form.submitted' in request.params:
|
||||
code = request.params['code']
|
||||
if 'form.submitted' in request.params:
|
||||
new_values = {}
|
||||
for param, db_value in expert.items():
|
||||
if param in request.params and request.params[param] != db_value:
|
||||
new_values[param] = request.params[param]
|
||||
|
||||
update_expert(request, code, libelle)
|
||||
request.session.flash(u"Le expert a été mis à jour avec succès.", 'success')
|
||||
|
||||
# en_activite coché ?
|
||||
if 'en_activite' in request.params:
|
||||
new_values['en_activite'] = 1
|
||||
else:
|
||||
new_values['en_activite'] = 0
|
||||
|
||||
if new_values:
|
||||
update_expert(request, code_cab, code_exp, new_values)
|
||||
request.session.flash(u"L'expert a été mis à jour avec succès.", 'success')
|
||||
return HTTPFound(location=request.route_url("cabinet_edit", code=code_cab))
|
||||
|
||||
if 'form.deleted' in request.params:
|
||||
delete_expert(request, code)
|
||||
request.session.flash(u"Le expert a été supprimé avec succès.", 'success')
|
||||
if 'form.deleted' in request.params:
|
||||
delete_expert(request, code_cab, code_exp)
|
||||
request.session.flash(u"L'expert a été supprimé avec succès.", 'success')
|
||||
return HTTPFound(location=request.route_url("cabinet_edit", code=code_cab))
|
||||
|
||||
return {
|
||||
'page_title': page_title,
|
||||
'url': url,
|
||||
'expert': expert,
|
||||
'experts': experts,
|
||||
'expert': expert,
|
||||
'code_exp': code_exp,
|
||||
'message': message,
|
||||
|
||||
Reference in New Issue
Block a user