Skip to content
Snippets Groups Projects
Commit cdb87141 authored by Andreas Valder's avatar Andreas Valder
Browse files

edit api is now logging changes

parent ea389d93
No related branches found
No related tags found
No related merge requests found
......@@ -164,8 +164,10 @@ def edit():
table, id, column = key.split('.', 2)
assert table in tabs
assert column in tabs[table][2]
query('INSERT INTO changelog ("table",id_value,id_key,field,value_new,value_old,"when",who,executed) VALUES (?,?,?,?,?,(SELECT %s FROM %s WHERE %s = ?),?,?,1)'%(column,tabs[table][0],tabs[table][1]),table,id,tabs[table][1],column,val,id,datetime.now(),session['user']['givenName'])
query('UPDATE %s SET %s = ? WHERE %s = ?'%(tabs[table][0], column,
tabs[table][1]), val, id)
query('COMMIT')
return "OK", 200
......@@ -254,4 +256,4 @@ def stats():
@register_navbar('Changelog', 'book')
@mod_required
def log():
return render_template('log.html', changelog=query('SELECT *, ( "table" || "." || id_value || "." ||field) as path FROM changelog ORDER BY "when" LIMIT 10'))
return render_template('log.html', changelog=query('SELECT *, ( "table" || "." || id_value || "." ||field) as path FROM changelog ORDER BY "when" DESC LIMIT 50'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment