forked from srinitude/AirBnB_clone_v2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.py
executable file
·32 lines (28 loc) · 1.02 KB
/
user.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
27
28
29
30
31
32
#!/usr/bin/python3
""" holds class User"""
from models.base_model import BaseModel, Base
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
from sqlalchemy.orm import relationship
import models
class User(BaseModel, Base):
"""Representation of a user """
if models.storage_type == "db":
__tablename__ = 'users'
email = Column(String(128), nullable=False)
password = Column(String(128), nullable=False)
first_name = Column(String(128), nullable=True)
last_name = Column(String(128), nullable=True)
places = relationship("Place",
backref="user",
cascade="delete")
reviews = relationship("Review",
backref="user",
cascade="delete")
else:
email = ""
password = ""
first_name = ""
last_name = ""
def __init__(self, *args, **kwargs):
"""initializes user"""
super().__init__(*args, **kwargs)