Commit f525d5d9 authored by Andreas Valder's avatar Andreas Valder
Browse files

worked on campus import

parent 614d4e44
......@@ -135,6 +135,14 @@ CREATE TABLE IF NOT EXISTS `stream_stats` (
`hls_720p` INTEGER NOT NULL DEFAULT '0',
`hls_360p` INTEGER NOT NULL DEFAULT '0'
);
CREATE TABLE IF NOT EXISTS `import_campus` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`course_id` INTEGER NOT NULL,
`last_checked` datetime NOT NULL,
`type` varchar(255),
`url` varchar(2084),
`changed` INTEGER NOT NULL DEFAULT '0'
);
CREATE TABLE IF NOT EXISTS `users` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`name` varchar(32) NOT NULL,
......
......@@ -33,6 +33,8 @@ if __name__ == '__main__':
config['SQLITE_INIT_DATA'] = True
config['DEBUG'] = True
config.from_pyfile('config.py', silent=True)
if config['DEBUG']:
app.jinja_env.auto_reload = True
from db import query, searchquery, ldapauth, ldapget
......@@ -322,16 +324,25 @@ def log():
changelog = query('SELECT *, ( "table" || "." || id_value || "." ||field) as path FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY "when" DESC LIMIT 50')
return render_template('log.html', changelog=changelog)
@app.route('/import/<source>/<id>')
@app.route('/import/<source>/<int:numid>')
@app.route('/import/<source>/<id>', methods=['GET', 'POST'])
@app.route('/import/<source>/<int:numid>', methods=['GET', 'POST'])
@handle_errors('course', 'Diese Veranstaltung existiert nicht!', 404, IndexError)
@mod_required
def import_from(numid=None, source=None, id=None):
if source != "campus":
return "Unknown source", 404
campus={}
for i in request.values:
group, id, field = i.split('.', 2)
if group == 'campus':
if not id in campus:
campus[id] = {}
campus[id][field] = request.values[i]
if numid:
courses = query('SELECT * FROM courses WHERE id = ?', numid)[0]
else:
courses = query('SELECT * FROM courses WHERE handle = ?', id)[0]
lectures = query('SELECT * FROM lectures WHERE course_id = ?', courses['id'])
return render_template('import_campus.html', course=courses, lectures=lectures)
return render_template('import_campus.html', course=courses, lectures=lectures, campus=campus)
......@@ -10,17 +10,22 @@
<div>
<p>Es folgen viele Pärchen an Campus-URL und Veranstaltungstyp Pärchen. Die Campus URL bekommt man aus dem Campus-System (<a href="https://www.campus.rwth-aachen.de/rwth/all/groups.asp">hier</a>). Der Veranstaltungstyp ist z.B. "Vorlesung" oder "Übung" oder "Praktikum".
</p>
<ul class="list-group row">
<li class="list-group-item form-inline">
<span class="input-group">
<input class="form-control" type="text" placeholder="url">
</span>
<span class="input-group">
<input class="form-control" type="test" placeholder="typ">
</span>
</li>
</ul>
<a class="btn btn-default pull-right">speichern und neu Laden</a>
<p>
{{ campus }}
</p>
<form method="post">
<ul class="list-group row">
<li class="list-group-item form-inline">
<span class="input-group">
<input class="form-control" type="text" name="campus.0.url" placeholder="url">
</span>
<span class="input-group">
<input class="form-control" type="test" name="campus.0.type" placeholder="type">
</span>
</li>
</ul>
<button class="btn btn-default pull-right" type="submit">speichern und neu Laden</button>
</form>
</div>
<div>
<ul class="list-group row">
......
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