last code clean up of the night

This commit is contained in:
crunk 2022-02-13 23:06:16 +01:00
parent 9d3978258d
commit 8857f17f7f
6 changed files with 10 additions and 13 deletions

View File

@ -17,10 +17,10 @@ login_manager = LoginManager()
def create_app(): def create_app():
APP = Flask(__name__, static_folder="static") APP = Flask(__name__, static_folder="static")
APP.secret_key = 'secret-key' APP.secret_key = "secret-key"
APP.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///data/distribusiverse.db" APP.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///data/distribusiverse.db"
APP.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True APP.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
#APP.config['MAX_CONTENT_LENGTH'] = 150 * 1024 * 1024 APP.config["MAX_CONTENT_LENGTH"] = 150 * 1024 * 1024
login_manager.session_protection = "strong" login_manager.session_protection = "strong"
login_manager.login_view = "index" login_manager.login_view = "index"
@ -28,8 +28,8 @@ def create_app():
csrf = CSRFProtect() csrf = CSRFProtect()
APP.config['SECRET_KEY'] = os.urandom(24) APP.config["SECRET_KEY"] = os.urandom(24)
APP.config['UPLOAD_FOLDER'] = 'tmpupload' APP.config["UPLOAD_FOLDER"] = "tmpupload"
csrf.init_app(APP) csrf.init_app(APP)
login_manager.init_app(APP) login_manager.init_app(APP)

View File

@ -6,6 +6,7 @@ def deploy():
# This model is required for flask_migrate to make the table # This model is required for flask_migrate to make the table
from usermodel import User # noqa: F401 from usermodel import User # noqa: F401
from distribusimodel import Distribusis # noqa: F401 from distribusimodel import Distribusis # noqa: F401
app = create_app() app = create_app()
app.app_context().push() app.app_context().push()
db.create_all() db.create_all()

View File

@ -7,7 +7,7 @@ class Distribusis(db.Model):
__tablename__ = "distribusis" __tablename__ = "distribusis"
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
distribusiname = db.Column(db.String(300), nullable=True, unique=True) distribusiname = db.Column(db.String(300), nullable=True, unique=True)
userid = db.Column(db.Integer, db.ForeignKey("users.id")) userid = db.Column(db.Integer, db.ForeignKey("users.id"))
term = db.Column(db.Integer, nullable=False, unique=False) term = db.Column(db.Integer, nullable=False, unique=False)

View File

@ -1,7 +1,5 @@
"""Form object declaration.""" """Form object declaration."""
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import validators
from wtforms import ( from wtforms import (
RadioField, RadioField,
SubmitField, SubmitField,
@ -10,12 +8,13 @@ from wtforms import (
class ThemeForm(FlaskForm): class ThemeForm(FlaskForm):
"""Publication upload form.""" """Publication upload form."""
theme = RadioField( theme = RadioField(
"Select your theme:", "Select your theme:",
choices=[ choices=[
("hacking", "Hacking"), ("hacking", "Hacking"),
("peachsunset", "Peach sunset"), ("peachsunset", "Peach sunset"),
("wdka", "WdkA") ("wdka", "WdkA"),
], ],
) )
save = SubmitField("Save") save = SubmitField("Save")

View File

@ -23,7 +23,6 @@ from flask_login import (
current_user, current_user,
) )
from flask_bcrypt import generate_password_hash
from flask_wtf.csrf import CSRFError from flask_wtf.csrf import CSRFError
from app import create_app, db, login_manager from app import create_app, db, login_manager
@ -31,7 +30,6 @@ from usermodel import User
from distribusimodel import Distribusis from distribusimodel import Distribusis
# Forms! # Forms!
from forms.registerform import RegisterForm
from forms.uploadform import UploadForm from forms.uploadform import UploadForm
from forms.distribusiform import DistribusiForm from forms.distribusiform import DistribusiForm
from forms.themeform import ThemeForm from forms.themeform import ThemeForm

View File

@ -11,6 +11,5 @@ class User(UserMixin, db.Model):
email = 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) password = db.Column(db.String(300), nullable=False, unique=False)
def __repr__(self): def __repr__(self):
return "<User %r>" % self.email return "<User %r>" % self.email