forked from alexaorrico/AirBnB_clone_v2
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
city.py
executable file
·26 lines (23 loc) · 813 Bytes
/
city.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python
""" holds class City"""
import models
from models.base_model import BaseModel, Base
from os import getenv
import sqlalchemy
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship
class City(BaseModel, Base):
"""Representation of city """
if models.storage_t == "db":
__tablename__ = 'cities'
state_id = Column(String(60), ForeignKey('states.id'), nullable=False)
name = Column(String(128), nullable=False)
places = relationship("Place",
backref="cities",
cascade="all, delete, delete-orphan")
else:
state_id = ""
name = ""
def __init__(self, *args, **kwargs):
"""initializes city"""
super().__init__(*args, **kwargs)