diff --git a/project/services/admin_unit.py b/project/services/admin_unit.py index 844e0b2..602a404 100644 --- a/project/services/admin_unit.py +++ b/project/services/admin_unit.py @@ -38,6 +38,14 @@ def insert_admin_unit_for_user(admin_unit, user): admin_unit.logo.encoding_format, ) db.session.add(organizer) + + # Place anlegen + place = EventPlace() + place.admin_unit_id = admin_unit.id + place.name = admin_unit.location.city + place.location = Location() + assign_location_values(place.location, admin_unit.location) + db.session.add(place) db.session.commit() diff --git a/project/services/place.py b/project/services/place.py index 84b7d69..91ba19c 100644 --- a/project/services/place.py +++ b/project/services/place.py @@ -4,13 +4,17 @@ from project import db from project.models import EventPlace, Location -def upsert_event_place(admin_unit_id, name): - result = EventPlace.query.filter( +def get_event_place(admin_unit_id, name): + return EventPlace.query.filter( and_( EventPlace.name == name, EventPlace.admin_unit_id == admin_unit_id, ) ).first() + + +def upsert_event_place(admin_unit_id, name): + result = get_event_place(admin_unit_id, name) if result is None: result = EventPlace(name=name, admin_unit_id=admin_unit_id) result.location = Location() diff --git a/project/templates/_macros.html b/project/templates/_macros.html index a731175..29b0644 100644 --- a/project/templates/_macros.html +++ b/project/templates/_macros.html @@ -660,7 +660,7 @@ {% endmacro %} -{% macro render_google_place_autocomplete_header(location_only = False) %} +{% macro render_google_place_autocomplete_header(location_only = False, prefix = '') %}