Skip to content
Snippets Groups Projects
Commit e7c30b5f authored by Martin Mareš's avatar Martin Mareš Committed by Jiří Setnička
Browse files

init-schools: db.School a db.Place se nyní musí joinovat

parent 8c04b74a
Branches
No related tags found
1 merge request!2Place editing
...@@ -63,7 +63,13 @@ def import_schools(path: Path, nuts: str): ...@@ -63,7 +63,13 @@ def import_schools(path: Path, nuts: str):
else: else:
assert False, f"Neznámý druh školy: {druh}" assert False, f"Neznámý druh školy: {druh}"
school = session.query(db.School).filter_by(level=4, parent=town.place_id, red_izo=red_izo, address=addr2).first() school = (session.query(db.School)
.join(db.Place)
.filter(db.Place.level == 4)
.filter(db.Place.parent == town.place_id)
.filter(db.School.red_izo == red_izo)
.filter(db.School.address == addr2)
.first())
if school: if school:
assert school.official_name == nazev assert school.official_name == nazev
if is_zs: if is_zs:
...@@ -71,11 +77,13 @@ def import_schools(path: Path, nuts: str): ...@@ -71,11 +77,13 @@ def import_schools(path: Path, nuts: str):
else: else:
school.is_ss = True school.is_ss = True
else: else:
school = db.School( place = db.Place(
level=4, level=4,
parent=town.place_id, parent=town.place_id,
name=nazev, name=nazev,
type=db.PlaceType.school, type=db.PlaceType.school)
school = db.School(
place=place,
red_izo=red_izo, red_izo=red_izo,
official_name=nazev, official_name=nazev,
address=addr2, address=addr2,
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment