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

switched campus import from romm name to room id, fixed "Kein raum zugewiesen"...

switched campus import from romm name to room id, fixed "Kein raum zugewiesen" closes #247, closes #241
parent efe29f1a
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,13 @@ def import_from(id): ...@@ -68,7 +68,13 @@ 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'] = ''
else:
rowdata['place'] = baserow.xpath("td[6]/a")[0].text_content()
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 +85,11 @@ def import_from(id): ...@@ -79,7 +85,11 @@ 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'] = ''
else:
rowdata['place'] = row.xpath("a")[0].text_content()
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 +102,14 @@ def import_from(id): ...@@ -92,11 +102,14 @@ 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']) 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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment