summer_course_2024/hub/persistence/models/city.py

37 lines
1.2 KiB
Python
Raw Permalink Normal View History

"""
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
"""
2023-01-31 13:11:39 -05:00
import datetime
from sqlalchemy import Column, Integer, String, Sequence, ForeignKey
2023-05-17 17:10:30 -04:00
from sqlalchemy import DateTime
from hub.persistence.configuration import Models
2023-01-31 13:11:39 -05:00
class City(Models):
"""A model representation of a city
"""
__tablename__ = 'city'
id = Column(Integer, Sequence('city_id_seq'), primary_key=True)
2023-02-13 05:17:25 -05:00
pickle_path = Column(String, nullable=False)
name = Column(String, nullable=False)
2023-07-26 15:03:31 -04:00
scenario = Column(String, nullable=False)
application_id = Column(Integer, ForeignKey('application.id', ondelete='CASCADE'), nullable=False)
user_id = Column(Integer, ForeignKey('user.id', ondelete='CASCADE'), nullable=True)
hub_release = Column(String, nullable=False)
2022-11-22 20:20:12 -05:00
created = Column(DateTime, default=datetime.datetime.utcnow)
updated = Column(DateTime, default=datetime.datetime.utcnow)
2023-07-26 15:03:31 -04:00
def __init__(self, pickle_path, name, scenario, application_id, user_id, hub_release):
2023-02-13 05:17:25 -05:00
self.pickle_path = str(pickle_path)
self.name = name
2023-07-26 15:03:31 -04:00
self.scenario = scenario
2023-01-31 13:11:39 -05:00
self.application_id = application_id
self.user_id = user_id
self.hub_release = hub_release