-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodels.py
31 lines (24 loc) · 1019 Bytes
/
models.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
# encoding: utf-8
from __future__ import absolute_import, print_function, unicode_literals
import datetime
from flask_login import UserMixin
from sqlalchemy import Column, Integer, String, Boolean
from pyms.models import db
class User(db.Model, UserMixin):
__tablename__ = 'auth_user'
date_joined = db.Column(db.DateTime, default=datetime.datetime.utcnow())
id = Column(Integer, primary_key=True, autoincrement=True)
email = Column(String, default="")
first_name = Column(String, default="")
last_name = Column(String, default="")
username = Column(String, nullable=False)
password = Column(String, nullable=False)
is_superuser = Column(Boolean, default=False)
is_staff = Column(Boolean, default=False)
is_active = Column(Boolean, default=True)
def __init__(self, username, password):
from project.views.oauth import bcrypt
self.username = username
self.password = bcrypt.generate_password_hash(
password, 13
).decode()