sunday developer
This commit is contained in:
parent
c77661e985
commit
12bb82a976
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,4 +10,5 @@ library/data/*.toc
|
|||||||
library/data/*.csv
|
library/data/*.csv
|
||||||
library/data/*.seg
|
library/data/*.seg
|
||||||
library/data/MAIN_WRITELOCK
|
library/data/MAIN_WRITELOCK
|
||||||
library/data/files/*.pdf
|
library/files/*.pdf
|
||||||
|
|
||||||
|
21
library/application/models/usermodel.py
Normal file
21
library/application/models/usermodel.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from app import db
|
||||||
|
from flask_login import UserMixin
|
||||||
|
|
||||||
|
|
||||||
|
class User(UserMixin, db.Model):
|
||||||
|
"""User model class for a user in the library"""
|
||||||
|
|
||||||
|
__tablename__ = "users"
|
||||||
|
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
username = db.Column(db.String(150), unique=True, nullable=False)
|
||||||
|
email = db.Column(db.String(150), unique=True, nullable=False)
|
||||||
|
password = db.Column(db.String(300), nullable=False, unique=False)
|
||||||
|
resethash = db.Column(db.String(300), nullable=True, unique=True)
|
||||||
|
resettime = db.Column(db.DateTime)
|
||||||
|
# active = db.Column(db.Boolean, default=False)
|
||||||
|
tutor = db.Column(db.Boolean, default=False)
|
||||||
|
admin = db.Column(db.Boolean, default=False)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<User %r>" % self.email
|
22
library/deploydb.py
Normal file
22
library/deploydb.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from app import create_app, db
|
||||||
|
from flask_migrate import upgrade, migrate, init, stamp
|
||||||
|
|
||||||
|
|
||||||
|
def deploy():
|
||||||
|
"""Run deployment of database."""
|
||||||
|
|
||||||
|
# This model is required for flask_migrate to make the table
|
||||||
|
from usermodel import User # noqa: F401
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
|
app.app_context().push()
|
||||||
|
db.create_all()
|
||||||
|
|
||||||
|
# migrate database to latest revision
|
||||||
|
init()
|
||||||
|
stamp()
|
||||||
|
migrate()
|
||||||
|
upgrade()
|
||||||
|
|
||||||
|
|
||||||
|
deploy()
|
0
library/files/files_here
Normal file
0
library/files/files_here
Normal file
@ -24,7 +24,7 @@ class RegisterForm(FlaskForm):
|
|||||||
validators.InputRequired(),
|
validators.InputRequired(),
|
||||||
Email(),
|
Email(),
|
||||||
Length(6, 64),
|
Length(6, 64),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
password = PasswordField(
|
password = PasswordField(
|
||||||
|
Loading…
Reference in New Issue
Block a user