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

Merge branch 'master' of git.fsmpi.rwth-aachen.de:videoagwebsite/videoagwebsite

parents 83d39362 ca4ecbc8
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,15 @@ def import_from(id): ...@@ -68,7 +68,15 @@ def import_from(id):
continue continue
baserow = baserow[0] baserow = baserow[0]
rowdata = {'dates': []} rowdata = {'dates': []}
rowdata['place'] = baserow.xpath("td[6]/text()")[0][2:-1]
# "kein raum vergeben" ist ein Sonderfall, ansonsten die campus id
if baserow.xpath("td[6]/text()")[0] == 'Kein Raum vergeben':
rowdata['place'] = ''
elif baserow.xpath("td[6]/a"):
rowdata['place'] = baserow.xpath("td[6]/a")[0].text_content()
else:
rowdata['place'] = baserow.xpath("td[6]/text()")[0].split(' ',1)[0]
rowdata['start'] = baserow.xpath("td[3]/text()")[0] rowdata['start'] = baserow.xpath("td[3]/text()")[0]
rowdata['end'] = baserow.xpath("td[5]/text()")[0] rowdata['end'] = baserow.xpath("td[5]/text()")[0]
rowdata['dates'] = baserow.getparent().xpath("tr[@class='hierarchy5']//td[@colspan='3']/text()") rowdata['dates'] = baserow.getparent().xpath("tr[@class='hierarchy5']//td[@colspan='3']/text()")
...@@ -79,7 +87,13 @@ def import_from(id): ...@@ -79,7 +87,13 @@ def import_from(id):
singletable = basetable.xpath("//table[@cellpadding='3']/tr/td[text()='Einmalige Termine:']")[0].getparent().getparent() singletable = basetable.xpath("//table[@cellpadding='3']/tr/td[text()='Einmalige Termine:']")[0].getparent().getparent()
for row in singletable.xpath("tr/td[2]"): for row in singletable.xpath("tr/td[2]"):
rowdata = {} rowdata = {}
rowdata['place'] = row.xpath("text()[2]")[0][2:-1] if row.xpath("text()[2]")[0] == 'Kein Raum vergeben':
rowdata['place'] = ''
elif row.xpath("a"):
rowdata['place'] = row.xpath("a")[0].text_content()
else:
rowdata['place'] = row.xpath("text()[2]")[0].split(' ',1)[0]
rowdata['dates'] = [row.xpath("text()[1]")[0][4:14]] rowdata['dates'] = [row.xpath("text()[1]")[0][4:14]]
rowdata['start'] = row.xpath("text()[1]")[0][17:22] rowdata['start'] = row.xpath("text()[1]")[0][17:22]
rowdata['end'] = row.xpath("text()[1]")[0][27:32] rowdata['end'] = row.xpath("text()[1]")[0][27:32]
...@@ -92,11 +106,15 @@ def import_from(id): ...@@ -92,11 +106,15 @@ def import_from(id):
fmt= "%d.%m.%Y %H:%M" fmt= "%d.%m.%Y %H:%M"
e['time'] = datetime.strptime("%s %s"%(k,j['start']) ,fmt) e['time'] = datetime.strptime("%s %s"%(k,j['start']) ,fmt)
e['duration'] = int((datetime.strptime("%s %s"%(k,j['end']) ,fmt) - e['time']).seconds/60) e['duration'] = int((datetime.strptime("%s %s"%(k,j['end']) ,fmt) - e['time']).seconds/60)
dbplace = query("SELECT name FROM places WHERE (campus_name = ?) OR ((NOT campus_name) AND name = ?)",j['place'],j['place']) j['place'] = str(j['place'])
if j['place'] != '':
dbplace = query("SELECT name FROM places WHERE (campus_room = ?) OR (campus_name = ?) OR ((NOT campus_name) AND name = ?)",j['place'],j['place'],j['place'])
if dbplace: if dbplace:
e['place'] = dbplace[0]['name'] e['place'] = dbplace[0]['name']
else: else:
e['place'] = 'Unbekannter Ort ('+j['place']+')' e['place'] = 'Unbekannter Ort ('+j['place']+')'
else:
e['place'] = ''
e['title'] = i['type'] e['title'] = i['type']
events.append(e) events.append(e)
# it is parsed. # it is parsed.
...@@ -106,11 +124,12 @@ def import_from(id): ...@@ -106,11 +124,12 @@ def import_from(id):
except ImportError: except ImportError:
flash('python-lxml not found, campus import will not work.') flash('python-lxml not found, campus import will not work.')
uniqueevents = [] # events to add
newevents = []
for i in events + lectures: for i in events + lectures:
unique = False unique = False
exists = False exists = False
for j in uniqueevents: for j in newevents:
unique = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration']) unique = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if unique: if unique:
break break
...@@ -119,7 +138,17 @@ def import_from(id): ...@@ -119,7 +138,17 @@ def import_from(id):
if exists: if exists:
break break
if (not unique) and (not exists): if (not unique) and (not exists):
i['type'] = 'import' newevents.append(i)
uniqueevents.append(i)
# deleted events
deletedlectures = []
for i in lectures:
incampus = False
for j in events:
incampus = (i['place'] == j['place']) and (i['time'] == j['time']) and (i['duration'] == j['duration'])
if incampus:
break
if not incampus:
deletedlectures.append(i)
return render_template('import_campus.html', course=courses, import_campus=import_campus, events=uniqueevents) return render_template('import_campus.html', course=courses, import_campus=import_campus, newevents=newevents, deletedlectures=deletedlectures)
...@@ -41,7 +41,10 @@ ...@@ -41,7 +41,10 @@
</span> </span>
</li> </li>
</ul> </ul>
<button class="btn btn-default pull-right" type="submit">Speichern</button> <ul class="list-inline pull-right">
<li><a class="btn btn-default" href="{{url_for('import_from', id=course['id'])}}"><span class="fa fa-refresh" aria-hidden="true" ></span> Campus abfragen</button></a></li>
<li><button class="btn btn-default" type="submit">Speichern</button></li>
</ul>
</form> </form>
</div> </div>
</div> </div>
...@@ -49,15 +52,57 @@ ...@@ -49,15 +52,57 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading" style="height:50px"> <div class="panel-heading" style="height:50px">
<h1 class="panel-title"> <h1 class="panel-title">
Fehlende Termine: Termine im Campus die nicht bei uns sind:
<ul class="list-inline pull-right"> <ul class="list-inline pull-right">
<li><a class="btn btn-default" href="{{url_for('import_from', id=course['id'])}}"><span class="fa fa-refresh" aria-hidden="true" ></span> Aktualisieren</button></a>
<li><button class="btn btn-default" onclick="$('.newlecture').click(); alert('done');">alle anlegen</button></li> <li><button class="btn btn-default" onclick="$('.newlecture').click(); alert('done');">alle anlegen</button></li>
</ul> </ul>
</h1> </h1>
</div> </div>
<ul class="list-group-item"> <ul class="list-group-item">
{% for i in events|sort(attribute='time') %} {% for i in newevents|sort(attribute='time') %}
<li class="list-group-item row">
<span class="col-xs-3">
Time: {{i.time}}
</span>
<span class="col-xs-2">
Duration: {{i.duration}}
</span>
<span class="col-xs-3">
Place: {{i.place}}
</span>
<span class="col-xs-3">
</span>
<span class="pull-right">
<button class="btn btn-default newlecture" onclick="moderator.api.gethttp('{{ url_for('create', table='lectures', course_id=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
</span>
</li>
{% endfor %}
</ul>
</div>
<div class="panel panel-default">
<div class="panel-heading" style="height:50px">
<h1 class="panel-title">
Termine bei uns die nicht im Campus sind:
<ul class="list-inline pull-right">
<li><button class="btn btn-default" onclick="deleteall(); alert('done');">alle entfernen</button></li>
<script>
function deleteall() {
var req = {};
{% for i in deletedlectures|sort(attribute='time') %}
req['lectures.{{ i.id }}.deleted'] = 1;
{% endfor %}
if (confirm('Really delete all lectures that are not in campus?')) {
moderator.api.set_multi(req,false);
}
}
</script>
</ul>
</h1>
</div>
<ul class="list-group-item">
{% for i in deletedlectures|sort(attribute='time') %}
<li class="list-group-item row"> <li class="list-group-item row">
<span class="col-xs-3"> <span class="col-xs-3">
Time: {{i.time}} Time: {{i.time}}
...@@ -69,26 +114,20 @@ ...@@ -69,26 +114,20 @@
Place: {{i.place}} Place: {{i.place}}
</span> </span>
<span class="col-xs-3"> <span class="col-xs-3">
{% if (i.type == 'lecture') %}
<p> <p>
{{i.comment}} {{i.comment}}
</p> </p>
<p> <p>
{{i.internal}} {{i.internal}}
</p> </p>
{% endif%}
</span> </span>
<span class="pull-right"> <span class="pull-right">
{% if (i.type == 'lecture') %}
{{ moderator_delete(['lectures',i.id,'deleted']) }} {{ moderator_delete(['lectures',i.id,'deleted']) }}
{% endif%}
{% if (i.type == 'import') %}
<button class="btn btn-default newlecture" onclick="moderator.api.gethttp('{{ url_for('create', table='lectures', course_id=course.id, time=i.time, title=i.title, place=i.place) }}')">anlegen</a>
{% endif%}
</span> </span>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment