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

Added basic editing api

parent c8209fbc
Branches
No related tags found
No related merge requests found
#!/bin/python
from flask import * from flask import *
from functools import wraps from functools import wraps
...@@ -205,5 +206,28 @@ def logout(): ...@@ -205,5 +206,28 @@ def logout():
else: else:
return redirect(url_for('index')) 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__': if __name__ == '__main__':
app.run() app.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment