ajout p_texts
This commit is contained in:
@@ -19,6 +19,11 @@ def execute_query(request, query, params):
|
||||
mark_changed(request.dbsession)
|
||||
transaction.commit()
|
||||
|
||||
def get_codespostaux(request, code):
|
||||
query = "SELECT * FROM p_codespostaux WHERE code_postal like :code;"
|
||||
results = request.dbsession.execute(query, {'code': code + "%"})
|
||||
return results.fetchall()
|
||||
|
||||
def get_member_by_mdp_oublie(request, lien):
|
||||
query = "SELECT * FROM p_users WHERE mdp_oublie=:lien;"
|
||||
results = request.dbsession.execute(query, {'lien':lien}).first()
|
||||
|
||||
@@ -82,3 +82,30 @@ def update_rdf_cause(request, old_code, code, libelle):
|
||||
else:
|
||||
query = "UPDATE rdf_causes SET code = :code, libelle = :libelle WHERE code = :old_code;"
|
||||
execute_query(request, query, {'old_code': old_code, 'code': code, 'libelle': libelle})
|
||||
|
||||
def get_texts(request, text_id):
|
||||
"""Lire les textes"""
|
||||
if text_id == 0:
|
||||
query = "SELECT * FROM p_texts ORDER BY theme, intitule;"
|
||||
results = request.dbsession.execute(query).fetchall()
|
||||
elif text_id == -1:
|
||||
query = "SELECT * FROM p_texts where theme != 'INTERNE' ORDER BY theme, intitule;"
|
||||
results = request.dbsession.execute(query).fetchall()
|
||||
else:
|
||||
query = "SELECT * FROM p_texts where text_id = :text_id;"
|
||||
results = request.dbsession.execute(query, {'text_id': text_id}).first()
|
||||
return results
|
||||
|
||||
def update_text(request, text_id, intitule, texte, theme):
|
||||
"""créér ou modifier la text"""
|
||||
if text_id == '0':
|
||||
query = "INSERT INTO p_texts (intitule, texte, theme) VALUES(:intitule, :texte, :theme);"
|
||||
execute_query(request, query, {'intitule': intitule, 'texte': texte, 'theme': theme})
|
||||
else:
|
||||
query = "update p_texts set intitule=:intitule, texte=:texte, theme=:theme where text_id = :text_id;"
|
||||
execute_query(request, query, {'text_id': text_id, 'intitule': intitule, 'texte': texte, 'theme': theme})
|
||||
|
||||
def delete_text(request, text_id):
|
||||
"""supprimer la text"""
|
||||
query = "delete from p_texts where text_id = :text_id;"
|
||||
execute_query(request, query, {'text_id': text_id})
|
||||
|
||||
@@ -7,6 +7,7 @@ def includeme(config):
|
||||
# default
|
||||
config.add_route('home', '/')
|
||||
config.add_route('affiche_message','/affiche_message/{login}')
|
||||
config.add_route('ajax_codepostal', '/ajax_codepostal')
|
||||
config.add_route('changer_mdp', '/changer_mdp')
|
||||
config.add_route('envoyer_mdp', '/envoyer_mdp')
|
||||
config.add_route('login', '/login')
|
||||
@@ -42,6 +43,9 @@ def includeme(config):
|
||||
config.add_route('orphans_de', '/orphans_de/{societe}')
|
||||
config.add_route('rdf_cause_edit', '/rdf_cause_edit/{code}')
|
||||
config.add_route('rdf_causes_list', '/rdf_causes_list')
|
||||
config.add_route('text_edit', '/text_edit/{text_id}')
|
||||
config.add_route('text_list', '/text_list')
|
||||
config.add_route('text_view', '/text_view/{text_id}')
|
||||
config.add_route('user_edit', '/user_edit/{cd_uti}')
|
||||
config.add_route('users_list', '/users_list')
|
||||
config.add_route('users_ua', '/users_ua')
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<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="change-dossier-details-form" class="form-horizontal" action="${url}" method="post" tal:condition="dossier"
|
||||
data-fv-framework="bootstrap"
|
||||
@@ -30,27 +32,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-4" for="C_CP">Code postal</label>
|
||||
<div class="col-xs-5">
|
||||
<input class="form-control" type="text" id="C_CP" name="C_CP" value="${dossier.C_CP}"
|
||||
<label class="control-label col-xs-4" for="code_postal">Code postal</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"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="5"
|
||||
data-fv-stringlength-message="5 caractères maximum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-4" for="C_VILLE">Ville</label>
|
||||
<div class="col-xs-5">
|
||||
<input class="form-control" type="text" id="C_VILLE" name="C_VILLE" value="${dossier.C_VILLE}"
|
||||
placeholder="45 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="La Ville est obligatoire"
|
||||
data-fv-stringlength="true"
|
||||
data-fv-stringlength-max="25"
|
||||
data-fv-stringlength-message="25 caractères maximum" />
|
||||
data-fv-notempty-message="Le code postal est obligatoire" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -62,6 +49,11 @@
|
||||
data-fv-stringlength-max="10"
|
||||
data-fv-stringlength-message="10 caractères maximum" />
|
||||
</div>
|
||||
<div class="col-sm-3 checkbox">
|
||||
<label><input type="checkbox" name="ascenseur" value="dossier.c_ascenseur" id="ascenseur"
|
||||
tal:attributes="checked dossier.c_ascenseur != 0 and 'checked' or None">Ascenceur
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">Code d'accès</label>
|
||||
@@ -91,7 +83,7 @@
|
||||
value="${dossier.C_TEL1}" placeholder="20 caractères maximum"
|
||||
data-fv-phone="true"
|
||||
data-fv-phone-country="FR"
|
||||
data-fv-phone-message="Ce numéro de téléphone n'est pas vailde" />
|
||||
data-fv-phone-message="Ce numéro de téléphone n'est pas valide" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -156,12 +148,28 @@
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#change-dossier-details-form').formValidation();
|
||||
$('form input').on('keypress', function(e) {
|
||||
return e.which !== 13;
|
||||
});
|
||||
$('#code_postal').autocomplete({
|
||||
source: function (request, response) {
|
||||
$.ajax({
|
||||
url:'/ajax_codepostal',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
recherche: request.term,
|
||||
},
|
||||
success: function (data) {
|
||||
response( data );
|
||||
},
|
||||
});
|
||||
},
|
||||
minLength: 3,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -84,7 +84,18 @@
|
||||
return '<a href="' + goto_url + data + '">' + data + '</a>';
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
"createdRow": function( row, data, dataIndex ){
|
||||
if ( data[6] == "Humidité" ) {
|
||||
$('td', row).eq(6).css('background-color', 'Crimson').css('color', 'white');
|
||||
}
|
||||
if ( data[6] == "En-cours" ) {
|
||||
$('td', row).eq(6).css('background-color', 'Orange');
|
||||
}
|
||||
if ( data[6] == "Terminé" ) {
|
||||
$('td', row).eq(6).css('background-color', 'LightGreen');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -24,11 +24,14 @@
|
||||
<tr>
|
||||
<td>
|
||||
Etage - Code<br />
|
||||
Ascenseur<br />
|
||||
Tél. domicile - prof.<br />
|
||||
Tél. mobile - fax
|
||||
</td>
|
||||
<td>
|
||||
${dossier.C_ETAGE} - ${dossier.C_CODE}<br />
|
||||
<span tal:condition="dossier.c_ascenseur==0">NON</span><br />
|
||||
<span tal:condition="dossier.c_ascenseur!=0">OUI</span><br />
|
||||
${dossier.C_TEL1} - ${dossier.C_TEL2}<br />
|
||||
${dossier.C_TELP} - ${dossier.C_FAX}
|
||||
</td>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<!-- Bootstrap core + Plug-ins CSS -->
|
||||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.css" rel="stylesheet">
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar-scheduler/1.9.4/scheduler.min.css" rel="stylesheet">
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
<a href="${request.application_url}/rdf_causes_list"><span class="glyphicon glyphicon-tint logo-primary"></span></a>
|
||||
<h4>RDF : CAUSES</h4>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<a href="${request.application_url}/text_list"><span class="glyphicon glyphicon-list-alt logo-primary"></span></a>
|
||||
<h4>TEXTES EMAIL</h4>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="row text-center">
|
||||
|
||||
69
mondumas/templates/parametres/text_edit.pt
Normal file
69
mondumas/templates/parametres/text_edit.pt
Normal file
@@ -0,0 +1,69 @@
|
||||
<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="text_edit-form" action="${url}" method="post" class="form-horizontal">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-2" for="intitule">Intitulé</label>
|
||||
<div class="col-xs-8">
|
||||
<input class="form-control" type="text" id="intitule" name="intitule" value="${intitule}"
|
||||
placeholder="40 caractères maximum"
|
||||
data-fv-notempty="true"
|
||||
data-fv-notempty-message="L'intitule est obligatoire"
|
||||
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="control-label col-xs-2" for="text-text">Texte</label>
|
||||
<div class="col-xs-8">
|
||||
<textarea class="form-control monospace-font" rows="15" cols="40" id="text-text" name="texte">${texte}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-2" for="theme">Thème</label>
|
||||
<div class="col-xs-4">
|
||||
<select class="form-control" id="theme" name="theme">
|
||||
<div tal:repeat="item themes">
|
||||
<option value="${item}" tal:attributes="selected theme==item and 'selected' or None">${item}</option>
|
||||
</div>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-8">
|
||||
<button class="btn btn-primary" type="submit" name="form.submitted">
|
||||
<span class="glyphicon glyphicon-ok"></span> Enregistrer</button>
|
||||
<a href="${request.application_url}/text_view/${text_id}" class="btn btn-default" role="button">
|
||||
<span class="glyphicon glyphicon-chevron-left"></span> Annuler</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" tal:condition="text_id != '0'">
|
||||
<div class="col-sm-offset-2 col-sm-8">
|
||||
<button class="btn btn-warning" type="submit" name="form.deleted">
|
||||
<span class="glyphicon glyphicon-remove"></span> Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
<br />
|
||||
</div> <!-- row -->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#text_edit-form').formValidation();
|
||||
$('form input').on('keypress', function(e) {
|
||||
return e.which !== 13;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</metal:block>
|
||||
31
mondumas/templates/parametres/text_list.pt
Normal file
31
mondumas/templates/parametres/text_list.pt
Normal file
@@ -0,0 +1,31 @@
|
||||
<metal:block use-macro="main_template">
|
||||
<div metal:fill-slot="content">
|
||||
|
||||
<div class="row">
|
||||
<p>
|
||||
<a href="text_edit/0" class="btn btn-success" role="button">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
Créer un nouveau texte</a>
|
||||
</p>
|
||||
<table class="table table-condensed table-striped table-bordered">
|
||||
<tr>
|
||||
<th>Intitulé</th>
|
||||
<th>Thème</th>
|
||||
<th>Dernière mise à jour</th>
|
||||
</tr>
|
||||
|
||||
<tr tal:repeat="ligne texts">
|
||||
<td><a href="text_view/${ligne.text_id}">${ligne.intitule}</a></td>
|
||||
<td>${ligne.theme}</td>
|
||||
<td><span tal:content="ligne.modif_le.strftime('%d/%m/%Y %H:%M')" /></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
</div>
|
||||
|
||||
</metal:block>
|
||||
|
||||
18
mondumas/templates/parametres/text_view.pt
Normal file
18
mondumas/templates/parametres/text_view.pt
Normal file
@@ -0,0 +1,18 @@
|
||||
<metal:block use-macro="main_template">
|
||||
<div metal:fill-slot="content">
|
||||
|
||||
<br />
|
||||
<a href="${request.application_url}/text_list" class="btn btn-default" role="button">
|
||||
<span class="glyphicon glyphicon-chevron-left"></span> Fermer</a>
|
||||
<a href="${request.application_url}/text_edit/${text_id}" class="btn btn-primary" role="button">
|
||||
<span class="glyphicon glyphicon-pencil"></span> Modifier</a>
|
||||
<br />
|
||||
<hr>
|
||||
<div tal:replace="structure texte">Page text goes here.</div>
|
||||
<hr>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
</div>
|
||||
</metal:block>
|
||||
@@ -263,4 +263,18 @@ def affiche_message(request):
|
||||
'url_identification': request.route_url('login_as', login=login)
|
||||
}
|
||||
|
||||
@view_config(route_name='ajax_codepostal')
|
||||
def ajax_codepostal(request):
|
||||
recherche = request.GET['recherche']
|
||||
|
||||
# lire les codes postaux commencant par
|
||||
items = get_codespostaux(request, recherche)
|
||||
|
||||
liste=[]
|
||||
for row in items:
|
||||
d = row.code_postal + " - " + row.libelle
|
||||
liste.append(d)
|
||||
|
||||
return Response(json.dumps(liste))
|
||||
|
||||
|
||||
|
||||
@@ -82,8 +82,12 @@ def dossier_lookup(request):
|
||||
message = "Chantier non trouvé : %s" % name
|
||||
# construire la liste
|
||||
for item in chantiers:
|
||||
if item.humidite != 0:
|
||||
status = 'Humidité'
|
||||
else:
|
||||
status = item.status
|
||||
d = ('%s-%s' % (societe, item.numero),item.date.strftime('%d-%m-%Y'), item.nomcli, item.chantier, to_euro(item.montant),
|
||||
item.nosin, item.status, item.usermaj)
|
||||
item.nosin, status, item.usermaj)
|
||||
liste.append(d)
|
||||
|
||||
if len(name) == 0 :
|
||||
@@ -254,12 +258,14 @@ def dossier_edit(request):
|
||||
logged_in = request.authenticated_userid
|
||||
nodossier = request.matchdict['nodossier']
|
||||
url = request.route_url('dossier_edit', nodossier=nodossier)
|
||||
message = ''
|
||||
|
||||
dossier = get_dossier_by_no(request, nodossier)
|
||||
if not dossier:
|
||||
request.session.flash(u"Le dossier no %s est introuvable" % (nodossier), 'danger')
|
||||
return HTTPFound(location=request.route_url('dossier_lookup'))
|
||||
|
||||
code_postal = '%s - %s' % (dossier.C_CP, dossier.C_VILLE)
|
||||
# lire table expert
|
||||
experts = get_experts(request, dossier.CABINET, 0)
|
||||
|
||||
@@ -269,7 +275,22 @@ def dossier_edit(request):
|
||||
if param in request.params and request.params[param] != db_value:
|
||||
new_values[param] = request.params[param]
|
||||
|
||||
if new_values:
|
||||
# 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:
|
||||
new_values['c_cp'] = cp[0]
|
||||
new_values['c_ville'] = cp[1]
|
||||
|
||||
# ascenseur coché ?
|
||||
if 'ascenseur' in request.params:
|
||||
new_values['c_ascenseur'] = 1
|
||||
else:
|
||||
new_values['c_ascenseur'] = 0
|
||||
|
||||
update_dossier(request, nodossier, new_values)
|
||||
request.session.flash(u"Le dossier a été mis à jour avec succès.", 'success')
|
||||
return HTTPFound(location=request.route_url('dossier_view', nodossier=nodossier))
|
||||
@@ -277,9 +298,11 @@ def dossier_edit(request):
|
||||
return {
|
||||
'page_title': "Modifier le dossier : %s" % nodossier,
|
||||
'url': url,
|
||||
'message': message,
|
||||
'dossier': dossier,
|
||||
'nodossier': nodossier,
|
||||
'experts': experts,
|
||||
'code_postal': code_postal,
|
||||
}
|
||||
|
||||
@view_config(route_name='upload_doc', renderer='../templates/dossier/upload_doc.pt', permission='view')
|
||||
|
||||
@@ -13,6 +13,7 @@ from pyramid.httpexceptions import (
|
||||
|
||||
from pyramid_mailer.message import Message, Attachment
|
||||
from datetime import *
|
||||
from docutils.core import publish_parts
|
||||
import hashlib
|
||||
|
||||
from sqlalchemy.exc import DBAPIError
|
||||
@@ -361,3 +362,83 @@ def emails_msg(request):
|
||||
return {
|
||||
'page_title': item.COMMENT,
|
||||
'item': item,
|
||||
}
|
||||
|
||||
@view_config(route_name='text_list', renderer='../templates/parametres/text_list.pt', permission='manage')
|
||||
def text_list(request):
|
||||
|
||||
# lire toutes les text
|
||||
texts = get_texts(request, 0)
|
||||
|
||||
return {
|
||||
'page_title': "Liste des textes",
|
||||
'texts': texts,
|
||||
}
|
||||
|
||||
@view_config(route_name='text_edit', renderer='../templates/parametres/text_edit.pt', permission='manage')
|
||||
def text_edit(request):
|
||||
text_id = request.matchdict['text_id']
|
||||
url = request.route_url('text_edit',text_id=text_id)
|
||||
|
||||
message = ""
|
||||
if text_id == '0':
|
||||
titre = "Nouvelle text"
|
||||
intitule = ""
|
||||
texte = ""
|
||||
theme = ""
|
||||
else:
|
||||
titre = "Modifier la text : %s" % str(text_id)
|
||||
text = get_texts(request, text_id)
|
||||
intitule = text.intitule
|
||||
texte = text.texte
|
||||
theme = text.theme
|
||||
|
||||
if 'form.submitted' in request.params:
|
||||
intitule = request.params["intitule"]
|
||||
texte = request.params["texte"]
|
||||
theme = request.params["theme"]
|
||||
|
||||
if len(intitule) > 0 and len(texte) > 0:
|
||||
update_text(request, text_id, intitule, texte, theme)
|
||||
if text_id == '0':
|
||||
# si creation text, retour à la liste des texts
|
||||
return HTTPFound(location=request.route_url('text_list'))
|
||||
else:
|
||||
return HTTPFound(location=request.route_url('text_view', text_id=text_id))
|
||||
else:
|
||||
message = "Veuillez saisir un intitule et un texte."
|
||||
|
||||
if 'form.deleted' in request.params:
|
||||
if text_id != '0':
|
||||
delete_text(request, text_id)
|
||||
request.session.flash("'%s' a été supprimée avec succès." % intitule, 'success')
|
||||
return HTTPFound(location=request.route_url('text_list'))
|
||||
|
||||
return {
|
||||
'page_title': titre,
|
||||
'url': url,
|
||||
'message': message,
|
||||
'text_id': text_id,
|
||||
'intitule': intitule,
|
||||
'texte': texte,
|
||||
'theme': theme,
|
||||
'themes': ["EMAIL","INTERNE"],
|
||||
}
|
||||
|
||||
@view_config(route_name='text_view', renderer='../templates/parametres/text_view.pt')
|
||||
def text_view(request):
|
||||
text_id = request.matchdict['text_id']
|
||||
current_route_path = request.current_route_path()
|
||||
|
||||
text = get_texts(request, text_id)
|
||||
intitule = text.intitule
|
||||
# insèrer le path de static/img
|
||||
img_path = '%s/static/img/' % request.application_url
|
||||
|
||||
texte = text.texte.replace('static/img/', img_path)
|
||||
# convertir reST en HTML
|
||||
texte = publish_parts(texte, writer_name='html')['html_body']
|
||||
return {
|
||||
'page_title': intitule,
|
||||
'texte': texte,
|
||||
'text_id': text_id,
|
||||
|
||||
Reference in New Issue
Block a user