Browse Source

remove distribusi user fields from copied model

main
crunk 3 months ago
parent
commit
544d3fa8a0
  1. 4
      .gitignore
  2. 30
      library/app.py
  3. 3
      library/application/models/usermodel.py
  4. 2
      library/deploydb.py

4
.gitignore

@ -6,9 +6,11 @@
build/
dist/
pip-wheel-metadata/
*.db
instance/*
migrations/*
library/data/*.toc
library/data/*.csv
library/data/*.seg
library/data/MAIN_WRITELOCK
library/files/*.pdf

30
library/app.py

@ -4,25 +4,49 @@ import tomllib
import flask_apscheduler
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_migrate import Migrate
from flask_wtf.csrf import CSRFProtect
from flask_login import (
LoginManager,
)
from whoosh.fields import *
from whoosh.index import create_in
from whoosh.qparser import QueryParser
from application.csvparser import CsvParser
db = SQLAlchemy()
migrate = Migrate()
bcrypt = Bcrypt()
login_manager = LoginManager()
SCRIPT_DIR = os.path.dirname(__file__)
DATA_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "data"))
def create_app():
settings = settings_from_file()
APP = Flask(__name__, static_folder="static")
APP.config["SECRET_KEY"] = "ty4425hk54a21eee5719b9s9df7sdfklx"
APP.config["SECRET_KEY"] = os.urandom(24)
APP.config["UPLOAD_FOLDER"] = "tmpupload"
APP.config["LIBRARY_FILENAME"] = settings["libaryfilename"]
APP.config["IMAGE_FOLDER"] = "static/images"
APP.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///libraryusers.db"
APP.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
APP.config["LIBRARY_FILENAME"] = settings["libaryfilename"]
APP.config["TITLE"] = settings["title"]
csrf = CSRFProtect(APP)
csrf.init_app(APP)
login_manager.init_app(APP)
db.init_app(APP)
migrate.init_app(APP, db, render_as_batch=True)
bcrypt.init_app(APP)
scheduler = flask_apscheduler.APScheduler()
scheduler.api_enabled = False
scheduler.init_app(APP)

3
library/application/models/usermodel.py

@ -13,9 +13,6 @@ class User(UserMixin, db.Model):
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

2
library/deploydb.py

@ -6,7 +6,7 @@ def deploy():
"""Run deployment of database."""
# This model is required for flask_migrate to make the table
from usermodel import User # noqa: F401
from application.models.usermodel import User # noqa: F401
app = create_app()
app.app_context().push()

Loading…
Cancel
Save