2015-12-23 06:26:27 +00:00
|
|
|
from flask.ext.sqlalchemy import SQLAlchemy
|
2015-12-23 23:23:18 +00:00
|
|
|
import utils
|
2015-12-23 06:26:27 +00:00
|
|
|
|
2015-12-23 19:49:31 +00:00
|
|
|
db = SQLAlchemy()
|
|
|
|
|
2015-12-23 23:06:44 +00:00
|
|
|
class Users(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
name = db.Column(db.String(64))
|
|
|
|
username = db.Column(db.String(64), unique=True)
|
|
|
|
username_lower = db.Column(db.String(64), unique=True)
|
|
|
|
email = db.Column(db.String(64), unique=True)
|
|
|
|
password = db.Column(db.String(128))
|
|
|
|
admin = db.Column(db.Boolean)
|
|
|
|
|
|
|
|
def __init__(self, name, username, email, password):
|
|
|
|
self.name = name
|
|
|
|
self.username = username
|
|
|
|
self.username_lower = username.lower()
|
|
|
|
self.email = email.lower()
|
2015-12-23 23:23:18 +00:00
|
|
|
self.password = utils.hash_password(password)
|