Commit 478c5c74 authored by Julian Rother's avatar Julian Rother
Browse files

Added basic editing api

parent c8209fbc
#!/bin/python
from flask import *
from functools import wraps
......@@ -205,5 +206,28 @@ def logout():
else:
return redirect(url_for('index'))
@app.route('/edit')
@login_required
def edit():
tabs = {
'courses': ('courses_data', 'id', ['visible', 'listed', 'title', 'short',
'handle', 'organizer', 'subject', 'credits', 'semester', 'downloadable',
'internal', 'responsible']),
'lectures': ('lectures_data', 'id', ['visible', 'title', 'comment',
'internal', 'speaker', 'place', 'time', 'duration', 'jumplist',
'titlefile']),
'site_texts': ('site_texts', 'key' ['value']),
'videos': ('videos_data', 'id', ['visible', 'downloadable', 'title',
'comment', 'internal'])
}
query('BEGIN TRANSACTION')
for key, val in request.get_json():
table, column, id = key.split('.', 2)
assert table in tabs
assert column in tabs[table][2]
query('UPDATE %s SET %s = ? WHERE %s = ?'%(tabs[table][0], column,
tabs[table][1]), val, id)
query('COMMIT TRANSACTION')
if __name__ == '__main__':
app.run()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment