You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
730 B
Python
24 lines
730 B
Python
7 years ago
|
from project import db
|
||
|
|
||
|
|
||
|
class User(db.Model):
|
||
|
__tablename__ = "users"
|
||
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||
|
username = db.Column(db.String(128), unique=True, nullable=False)
|
||
|
email = db.Column(db.String(128), unique=True, nullable=False)
|
||
|
active = db.Column(db.Boolean, default=True, nullable=False)
|
||
|
admin = db.Column(db.Boolean, default=False, nullable=False)
|
||
|
|
||
|
def __init__(self, username, email):
|
||
|
self.username = username
|
||
|
self.email = email
|
||
|
|
||
|
def to_json(self):
|
||
|
return {
|
||
|
'id': self.id,
|
||
|
'username': self.username,
|
||
|
'email': self.email,
|
||
|
'active': self.active,
|
||
|
'admin': self.admin
|
||
|
}
|