-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuser.py
31 lines (27 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
"""
Define the User model
"""
from . import db
from .abc import BaseModel
import datetime
class User(db.Model, BaseModel):
""" The User model """
__tablename__ = 'user'
id = db.Column(db.Integer,primary_key=True)
first_name = db.Column(db.String(300))
last_name = db.Column(db.String(300))
email = db.Column(db.String(300), unique=True, nullable=False)
password = db.Column(db.String(300), nullable=False)
created_at = db.Column(db.DateTime)
modified_at = db.Column(db.DateTime)
subscriptions = db.relationship('podcast_show', backref='user', lazy=True)
def __init__(self, id, first_name, last_name, email, password, created_at, modified_at, subscriptions=None):
""" Create a new User """
self.id = id
self.first_name = first_name
self.last_name = last_name
self.email = email
self.password = password
self.created_at = datetime.datetime.utcnow()
self.modified_at = datetime.datetime.utcnow()
self.subscriptions = subscriptions