bug creation doc

This commit is contained in:
2020-05-06 14:43:02 +02:00
parent a0678fd949
commit 44986cd5f4
3 changed files with 22 additions and 13 deletions

View File

@@ -51,14 +51,22 @@ def get_docs_bycritere(request, critere):
results = request.dbsession.execute(query, {'critere': '%' + critere + '%'}).fetchall()
return results
def update_doc(request, doc_id, intitule, texte, theme):
def update_doc(request, doc_id, new_values):
"""créér ou modifier le doc"""
# formater les champs
s = ''
for param in new_values.keys():
if s:
s += ",%s=:%s" % (param, param)
else:
s = "%s=:%s" % (param, param)
if doc_id == '0':
query = "INSERT INTO docs (intitule, texte, theme) VALUES(:intitule, :texte, :theme);"
execute_query(request, query, {'intitule': intitule, 'texte': texte, 'theme': theme})
query = "INSERT INTO docs SET %s;" % s
else:
query = "update docs set intitule=:intitule, texte=:texte, theme=:theme where doc_id = :doc_id;"
execute_query(request, query, {'doc_id': doc_id, 'intitule': intitule, 'texte': texte, 'theme': theme})
new_values['doc_id'] = doc_id
query = "update docs SET %s WHERE doc_id = :doc_id;" % s
execute_query(request, query, new_values)
def delete_doc(request, doc_id):
"""supprimer la doc"""