mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 16:14:36 +00:00
23 lines
797 B
Python
23 lines
797 B
Python
from models import Location
|
|
|
|
def upsert_location(street, postalCode, city, latitude = 0, longitude = 0, state = None):
|
|
result = Location.query.filter_by(street = street, postalCode=postalCode, city=city, state=state).first()
|
|
if result is None:
|
|
result = Location(street = street, postalCode=postalCode, city=city, state=state)
|
|
db.session.add(result)
|
|
|
|
result.latitude = latitude
|
|
result.longitude = longitude
|
|
|
|
return result
|
|
|
|
|
|
def assign_location_values(target, origin):
|
|
if origin:
|
|
target.street = origin.street
|
|
target.postalCode = origin.postalCode
|
|
target.city = origin.city
|
|
target.state = origin.state
|
|
target.country = origin.country
|
|
target.latitude = origin.latitude
|
|
target.longitude = origin.longitude |