forked from justinmajetich/AirBnB_clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.py
31 lines (26 loc) · 932 Bytes
/
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
#!/usr/bin/python3
"""This module defines a class User"""
from models.base_model import BaseModel, Base
import sqlalchemy
from sqlalchemy import Column, String
from sqlalchemy.orm import relationship
import os
class User(BaseModel, Base):
"""This class defines a user by various attributes"""
if os.environ.get('HBNB_TYPE_STORAGE') == 'db':
__tablename__ = 'users'
email = Column(String(128), nullable=False)
password = Column(String(128), nullable=False)
first_name = Column(String(128))
last_name = Column(String(128))
places = relationship('Place', cascade='all, delete',
backref='user')
reviews = relationship('Review', cascade='all, delete',
backref='user')
else:
email = ""
password = ""
first_name = ""
last_name = ""
places = []
reviews = []