ajout p_texts

This commit is contained in:
2020-03-12 22:33:40 +01:00
parent 932fc6a441
commit ae4484374f
14 changed files with 327 additions and 28 deletions

View File

@@ -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})