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

made campus import less painfull and faster. closes #123

parent 38f098b6
......@@ -2,11 +2,9 @@ from server import *
@app.route('/import/<int:id>', methods=['GET', 'POST'])
@mod_required
def import_from(id):
def list_import_sources(id):
courses = query('SELECT * FROM courses WHERE id = ?', id)[0]
lectures = query('SELECT * FROM lectures WHERE course_id = ?', courses['id'])
campus={}
for i in request.values:
group, importid, field = i.split('.', 2)
......@@ -23,6 +21,17 @@ def import_from(id):
query('UPDATE import_campus SET url = ?, `type` = ? WHERE (course_id = ?) AND (id = ?)', campus[i]['url'],campus[i]['type'],id,int(i))
else:
query('DELETE FROM import_campus WHERE (id = ?) AND (course_id = ?)',int(i),id)
import_campus = query('SELECT * FROM import_campus WHERE course_id = ?',id)
return render_template('import_campus.html', course=courses, import_campus=import_campus, events=[])
@app.route('/import/<int:id>/now', methods=['GET', 'POST'])
@mod_required
def import_from(id):
courses = query('SELECT * FROM courses WHERE id = ?', id)[0]
lectures = query('SELECT * FROM lectures WHERE course_id = ?', courses['id'])
import_campus = query('SELECT * FROM import_campus WHERE course_id = ?',id)
events = []
......
......@@ -482,9 +482,7 @@ def create(table):
args = request.values.items()
if (request.method == 'POST') and (request.get_json()):
args = request.get_json().items()
print(args)
for column, val in args:
print(column,val)
if (column == 'ref') or (column == '_csrf_token'):
continue
assert column in tabs[table][2]+tabs[table][3]
......
......@@ -51,7 +51,7 @@
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Videos{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="{{ url_for('create', table='lectures', time=datetime.now(), title='Noch kein Titel', visible='0', course_id=course.id, ref=request.url) }}">Neuer Termin</a><a class="btn btn-default" style="margin-right: 5px;" href="{{url_for('import_from', id=course['id'])}}">Campus Import</a>{% endif %} <a class="fa fa-rss-square pull-right" aria-hidden="true" href="{{url_for('feed', handle=course.handle)}}" style="text-decoration: none"></a> </h1>
<h1 class="panel-title">Videos{% if ismod() %} <a class="btn btn-default" style="margin-right: 5px;" href="{{ url_for('create', table='lectures', time=datetime.now(), title='Noch kein Titel', visible='0', course_id=course.id, ref=request.url) }}">Neuer Termin</a><a class="btn btn-default" style="margin-right: 5px;" href="{{url_for('list_import_sources', id=course['id'])}}">Campus Import</a>{% endif %} <a class="fa fa-rss-square pull-right" aria-hidden="true" href="{{url_for('feed', handle=course.handle)}}" style="text-decoration: none"></a> </h1>
</div>
<ul class="list-group lectureslist">
{% for l in lectures %}
......
......@@ -10,7 +10,7 @@
<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" target="_blank">hier</a>). Der Veranstaltungstyp ist z.B. "Vorlesung" oder "Übung" oder "Praktikum".
</p>
<form method="post">
<form method="post" action="{{url_for('list_import_sources', id=course['id'])}}">
<ul class="list-group row" style="margin-left: 0px; margin-right: 0px;">
{%for i in import_campus %}
<li class="list-group-item form-inline row">
......@@ -41,14 +41,20 @@
</span>
</li>
</ul>
<button class="btn btn-default pull-right" type="submit">speichern und neu Laden</button>
<button class="btn btn-default pull-right" type="submit">Speichern</button>
</form>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Fehlende Termine: <button class="pull-right btn btn-default" onclick="$('.newlecture').click()">alle anlagen</button></h1>
<div class="panel-heading" style="height:50px">
<h1 class="panel-title">
Fehlende Termine:
<ul class="list-inline pull-right">
<li><a class="btn btn-default" href="{{url_for('import_from', id=course['id'])}}">Campus überprüfen (Warnung: dauert lange)</button></a>
<li><button class="btn btn-default" onclick="$('.newlecture').click(); alert(\"done\");">alle anlagen</button></li>
</ul>
</h1>
</div>
<ul class="list-group-item">
{% for i in events|sort(attribute='time') %}
......
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