diff --git a/app/__init__.py b/app/__init__.py index 756b8ed..d1589fa 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -5,7 +5,6 @@ from flask_assets import Environment from webassets import Bundle import time from app.models import db, migrate, PlayKey -from app.schemas import ma from app.forms import CustomUserManager from flask_user import user_registered, current_user, user_logged_in from flask_wtf.csrf import CSRFProtect @@ -128,8 +127,6 @@ def register_extensions(app): """ db.init_app(app) migrate.init_app(app, db) - ma.init_app(app) - scheduler.init_app(app) scheduler.start() diff --git a/app/accounts.py b/app/accounts.py index ffb1e0f..4a1e570 100644 --- a/app/accounts.py +++ b/app/accounts.py @@ -19,16 +19,12 @@ from app.models import ( db, Friends ) -from app.schemas import AccountSchema from app import gm_level, log_audit from app.forms import EditGMLevelForm, EditEmailForm from sqlalchemy import or_ accounts_blueprint = Blueprint('accounts', __name__) -account_schema = AccountSchema() - - @accounts_blueprint.route('/', methods=['GET']) @login_required @gm_level(3) diff --git a/app/characters.py b/app/characters.py index 7c65939..41c9ff8 100644 --- a/app/characters.py +++ b/app/characters.py @@ -3,7 +3,6 @@ from flask_user import login_required, current_user from datatables import ColumnDT, DataTables import time from app.models import CharacterInfo, CharacterXML, Account, db -from app.schemas import CharacterInfoSchema from app.forms import RescueForm, CharXMLUploadForm from app import gm_level, log_audit from app.luclient import translate_from_locale @@ -15,9 +14,6 @@ from xml.dom import minidom character_blueprint = Blueprint('characters', __name__) -character_schema = CharacterInfoSchema() - - @character_blueprint.route('/', methods=['GET']) @login_required @gm_level(3) diff --git a/app/main.py b/app/main.py index 862ee45..ad2587d 100644 --- a/app/main.py +++ b/app/main.py @@ -2,16 +2,12 @@ from flask import render_template, Blueprint, send_from_directory from flask_user import current_user, login_required from app.models import Account, CharacterInfo, ActivityLog -from app.schemas import AccountSchema, CharacterInfoSchema import datetime import time main_blueprint = Blueprint('main', __name__) -account_schema = AccountSchema() -char_info_schema = CharacterInfoSchema() - @main_blueprint.route('/', methods=['GET']) def index(): diff --git a/app/models.py b/app/models.py index 566d9a3..21b2ba9 100644 --- a/app/models.py +++ b/app/models.py @@ -4,7 +4,7 @@ from flask_user import UserMixin from wtforms import ValidationError import logging -from flask_sqlalchemy import BaseQuery +from flask_sqlalchemy.query import Query from sqlalchemy.dialects import mysql from sqlalchemy.exc import OperationalError, StatementError from sqlalchemy.types import JSON @@ -15,7 +15,7 @@ import string # retrying query to work around python trash collector # killing connections of other gunicorn workers -class RetryingQuery(BaseQuery): +class RetryingQuery(Query): __retry_count__ = 3 def __init__(self, *args, **kwargs): diff --git a/app/properties.py b/app/properties.py index 3b03d5a..f661f59 100644 --- a/app/properties.py +++ b/app/properties.py @@ -13,7 +13,6 @@ from flask_user import login_required, current_user from datatables import ColumnDT, DataTables import time from app.models import Property, db, UGC, CharacterInfo, PropertyContent, Account, Mail -from app.schemas import PropertySchema from app import gm_level, log_audit from app.luclient import query_cdclient from app.forms import RejectPropertyForm @@ -24,9 +23,6 @@ import pathlib property_blueprint = Blueprint('properties', __name__) -property_schema = PropertySchema() - - @property_blueprint.route('/', methods=['GET']) @login_required @gm_level(3) diff --git a/app/schemas.py b/app/schemas.py deleted file mode 100644 index b9e1b18..0000000 --- a/app/schemas.py +++ /dev/null @@ -1,130 +0,0 @@ -from flask_marshmallow import Marshmallow -from app.models import ( - PlayKey, - PetNames, - Mail, - UGC, - PropertyContent, - Property, - CharacterXML, - CharacterInfo, - Account, - AccountInvitation, - ActivityLog, - CommandLog -) -ma = Marshmallow() - - -class PlayKeySchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = PlayKey - include_relationships = False - load_instance = True - include_fk = True - - -class PetNamesSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = PetNames - include_relationships = False - load_instance = True - include_fk = False - - -class MailSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = Mail - include_relationships = False - load_instance = True - include_fk = False - - -class UGCSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = UGC - include_relationships = False - load_instance = True - include_fk = False - - -class PropertyContentSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = PropertyContent - include_relationships = True - load_instance = True - include_fk = True - - ugc = ma.Nested(UGCSchema) - - -class PropertySchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = Property - include_relationships = False - load_instance = True - include_fk = False - - properties_contents = ma.Nested(PropertyContentSchema, many=True) - - -class CharacterXMLSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = CharacterXML - include_relationships = False - load_instance = True - include_fk = False - - -class CharacterInfoSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = CharacterInfo - include_relationships = False - load_instance = True - include_fk = False - - charxml = ma.Nested(CharacterXMLSchema) - properties_owner = ma.Nested(PropertySchema, many=True) - pets = ma.Nested(PetNamesSchema, many=True) - mail = ma.Nested(MailSchema, many=True) - - -class AccountSchema(ma.SQLAlchemyAutoSchema): - class Meta: - model = Account - include_relationships = False - load_instance = True - include_fk = False - - play_key = ma.Nested(PlayKeySchema) - charinfo = ma.Nested(CharacterInfoSchema, many=True) - - -class AccountInvitationSchema(ma.SQLAlchemyAutoSchema): # noqa - class Meta: - model = AccountInvitation - include_relationships = True - load_instance = True - include_fk = True - - invite_by_user = ma.Nested(AccountSchema) - - -class ActivityLogSchema(ma.SQLAlchemyAutoSchema): # noqa - class Meta: - model = ActivityLog - include_relationships = True - load_instance = True - include_fk = True - - character = ma.Nested(CharacterInfoSchema()) - - -class CommandLogSchema(ma.SQLAlchemyAutoSchema): # noqa - class Meta: - model = CommandLog - include_relationships = True - load_instance = True - include_fk = True - - character = ma.Nested(CharacterInfoSchema()) diff --git a/requirements.txt b/requirements.txt index 0162f7e..6393bbb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,37 +2,42 @@ alembic==1.7.5 APScheduler==3.8.1 astroid==2.9.1 autopep8==1.6.0 +backports.zoneinfo==0.2.1 bcrypt==3.2.0 -blinker==1.4 +blinker==1.7.0 cffi==1.14.6 -click==8.0.1 +click==8.1.7 colorama==0.4.4 cryptography==36.0.0 dnspython==2.1.0 dominate==2.6.0 email-validator==1.1.3 -Flask==2.0.1 +Flask==3.0.0 Flask-APScheduler==1.12.3 -Flask-Assets==2.0 -Flask-Login==0.5.0 +Flask-Assets==2.1.0 +Flask-Login==0.6.3 Flask-Mail==0.9.1 -flask-marshmallow==0.14.0 +flask-marshmallow==0.15.0 Flask-Migrate==3.1.0 -Flask-SQLAlchemy==2.5.1 +Flask-SQLAlchemy==3.1.1 Flask-User==1.0.2.2 -Flask-WTF==1.0.0 +Flask-WTF==1.2.1 greenlet==1.1.0 +gunicorn==21.2.0 idna==3.3 +importlib-metadata==6.8.0 +importlib-resources==6.1.1 isort==5.10.1 -itsdangerous==2.0.1 -Jinja2==3.0.1 +itsdangerous==2.1.2 +Jinja2==3.1.2 lazy-object-proxy==1.7.1 libsass==0.21.0 Mako==1.2.2 -MarkupSafe==2.0.1 +MarkupSafe==2.1.3 marshmallow==3.14.1 marshmallow-sqlalchemy==0.26.1 mccabe==0.6.1 +packaging==23.2 passlib==1.7.4 platformdirs==2.4.1 pycodestyle==2.8.0 @@ -47,15 +52,17 @@ pytz==2021.3 pytz-deprecation-shim==0.1.0.post0 six==1.16.0 snowballstemmer==2.2.0 -SQLAlchemy==1.4.22 +SQLAlchemy==2.0.23 sqlalchemy-datatables==2.0.1 toml==0.10.2 +typing_extensions==4.8.0 tzdata==2021.5 tzlocal==4.1 visitor==0.1.3 Wand==0.6.7 webassets==2.0 -Werkzeug==2.0.1 +Werkzeug==3.0.1 wrapt==1.13.3 WTForms==3.0.0 xmltodict==0.12.0 +zipp==3.17.0