Skip to content
Snippets Groups Projects
Commit 0515eea9 authored by Andreas Valder's avatar Andreas Valder
Browse files

campus import fully working

parent 594a9213
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,6 @@ def import_from(source=None, id=None):
e['duration'] = int((datetime.strptime("%s %s"%(k,j['end']) ,fmt) - e['time']).seconds/60)
e['place'] = query("SELECT name FROM places WHERE (campus_name = ?) OR ((NOT campus_name) AND name = ?)",j['place'],j['place'])[0]['name'];
e['title'] = i['type']
e['exists'] = len(query("SELECT id from lectures WHERE (time = ?) and (duration = ?) and (place = ?) and (course_id = ?)",e['time'],e['duration'],e['place'],id)) > 0
events.append(e)
# it is parsed.
......@@ -91,24 +90,19 @@ def import_from(source=None, id=None):
flash('python-lxml not found, campus import will not work.')
uniqueevents = []
for i in events:
seen = False
for i in events + lectures:
unique = False
exists = False
for j in uniqueevents:
seen = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if seen:
unique = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if unique:
break
if (not seen) and (not i['exists']):
i['type'] = 'import'
uniqueevents.append(i)
for i in lectures:
i['hascampusmapping'] = False
for j in events:
i['hascampusmapping'] = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if i['hascampusmapping']:
for j in lectures:
exists = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if exists:
break
if not i['hascampusmapping']:
i['type'] = 'lecture'
if (not unique) and (not exists):
i['type'] = 'import'
uniqueevents.append(i)
return render_template('import_campus.html', course=courses, import_campus=import_campus, events=uniqueevents)
......@@ -258,6 +258,7 @@ def edit(prefix="", ignore=[]):
if key in ignore:
continue
key = prefix+key
print (key,val)
table, id, column = key.split('.', 2)
assert table in tabs
assert column in tabs[table][2]
......
......@@ -66,6 +66,13 @@ var moderatorinterface = {
if (confirm('Realy delete this?')) {
moderatorinterface.set($(src).data('path'),1,true);
}
},
gethttp: function (url){
$.ajax({
method: "GET",
url: url,
dataType: "text",
})
}
};
......
......@@ -57,7 +57,7 @@
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">Fehlende Termine:</h1>
<h1 class="panel-title">Fehlende Termine: <button class="pull-right btn btn-default" onclick="$('.newlecture').click()">alle anlagen</button></h1>
</div>
<ul class="list-group-item">
{% for i in events|sort(attribute='time') %}
......@@ -86,11 +86,11 @@
</span>
<span class="col-xs-1">
<span class="pull-right">
{% if (i.type == 'lecture') and (not i.hascampusmapping) %}
{% if (i.type == 'lecture') %}
{{ valuedeletebtn(['lectures',i.id,'deleted']) }}
{% endif%}
{% if (i.type == 'import') and (not i.exists) %}
anlegen
{% if (i.type == 'import') %}
<button class="btn btn-default newlecture" onclick="moderatorinterface.gethttp('{{ url_for('new_lecture', courseid=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
{% endif%}
</span>
</span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment