Skip to content
Snippets Groups Projects
Commit 87e950e2 authored by Julian Rother's avatar Julian Rother
Browse files

Make 'edit' update time_updated

parent 6045cbbb
No related branches found
No related tags found
No related merge requests found
...@@ -219,13 +219,13 @@ def logout(): ...@@ -219,13 +219,13 @@ def logout():
@app.route('/edit', methods=['GET', 'POST']) @app.route('/edit', methods=['GET', 'POST'])
@mod_required @mod_required
def edit(prefix="", ignore=[]): def edit(prefix="", ignore=[]):
# All editable tables are expected to have a 'time_updated' field
tabs = { tabs = {
'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short', 'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short',
'handle', 'organizer', 'subject', 'semester', 'downloadable', 'handle', 'organizer', 'subject', 'semester', 'downloadable',
'internal', 'responsible','deleted']), 'internal', 'responsible','deleted']),
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment', 'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']), 'internal', 'speaker', 'place', 'time', 'duration', 'jumplist','deleted']),
'site_texts': ('site_texts', 'key', ['value']),
'videos': ('videos_data', 'id', ['visible','deleted']), 'videos': ('videos_data', 'id', ['visible','deleted']),
'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted']) 'chapters': ('chapters', 'id', ['time', 'text', 'visible', 'deleted'])
} }
...@@ -242,7 +242,7 @@ def edit(prefix="", ignore=[]): ...@@ -242,7 +242,7 @@ def edit(prefix="", ignore=[]):
assert table in tabs assert table in tabs
assert column in tabs[table][2] 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('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('UPDATE %s SET %s = ?, time_updated = ? WHERE %s = ?'%(tabs[table][0], column, tabs[table][1]), val, datetime.now(), id)
query('COMMIT') query('COMMIT')
return "OK", 200 return "OK", 200
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment