2022-11-03 12:49:39 -04:00
|
|
|
"""
|
|
|
|
Model representation of a City
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Peter Yefi peteryefi@gmail.com
|
|
|
|
"""
|
|
|
|
|
|
|
|
from sqlalchemy import Column, Integer, String, Sequence, Float
|
2022-11-03 15:29:09 -04:00
|
|
|
from persistence.db_config import Base
|
2022-11-03 12:49:39 -04:00
|
|
|
from sqlalchemy.orm import relationship
|
|
|
|
|
|
|
|
|
|
|
|
class City(Base):
|
2022-11-03 15:29:09 -04:00
|
|
|
"""A model representation of a city
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
name The name of the city.
|
|
|
|
uid A unique identifier for each city object
|
|
|
|
location The location of the building.
|
|
|
|
country_code The country where the city is located.
|
|
|
|
latitude The GPS latitude location of the city.
|
|
|
|
longitude The GPS longitude location of the city.
|
|
|
|
building A relationship for fetching all buildings in the city
|
|
|
|
"""
|
|
|
|
__tablename__ = "city"
|
2022-11-03 12:49:39 -04:00
|
|
|
id = Column(Integer, Sequence('city_id_seq'), primary_key=True)
|
|
|
|
name = Column(String, nullable=False)
|
2022-11-03 15:29:09 -04:00
|
|
|
time_zone = Column(String, nullable=True)
|
2022-11-03 12:49:39 -04:00
|
|
|
country_code = Column(String, nullable=False)
|
2022-11-03 15:29:09 -04:00
|
|
|
latitude = Column(Float)
|
|
|
|
longitude = Column(Float)
|
2022-11-08 21:03:48 -05:00
|
|
|
buildings = relationship('Building', backref='city', lazy=True, cascade="all, delete-orphan")
|