ajout p_texts
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
|
||||
@@ -81,9 +81,13 @@ def dossier_lookup(request):
|
||||
if len(chantiers) == 0:
|
||||
message = "Chantier non trouvé : %s" % name
|
||||
# construire la liste
|
||||
for item in chantiers:
|
||||
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