From cdb871415095d1cdb5c7ef3e9da12452178b1042 Mon Sep 17 00:00:00 2001
From: Andreas Valder <andreasv@fsmpi.rwth-aachen.de>
Date: Thu, 1 Sep 2016 18:12:59 +0200
Subject: [PATCH] edit api is now logging changes

---
 server.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/server.py b/server.py
index 4a1d9ed..82f2616 100755
--- a/server.py
+++ b/server.py
@@ -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'))
-- 
GitLab