From de0ba444e6e535f0e97fb6ee987171175bfef4f0 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Wed, 23 Dec 2015 17:06:44 -0600 Subject: [PATCH] added user model --- server/api/__init__.py | 4 +++- server/api/models.py | 16 ++++++++++++++++ server/api/user.py | 0 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 server/api/user.py diff --git a/server/api/__init__.py b/server/api/__init__.py index 2c4eac3..8f72dae 100644 --- a/server/api/__init__.py +++ b/server/api/__init__.py @@ -1 +1,3 @@ -import models \ No newline at end of file +import models +import utils +import user \ No newline at end of file diff --git a/server/api/models.py b/server/api/models.py index c3ddbfe..f17d203 100644 --- a/server/api/models.py +++ b/server/api/models.py @@ -1,4 +1,20 @@ from flask.ext.sqlalchemy import SQLAlchemy +import api.utils db = SQLAlchemy() +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() + self.password = api.utils.hash_password(password) \ No newline at end of file diff --git a/server/api/user.py b/server/api/user.py new file mode 100644 index 0000000..e69de29