Skip to content

Commit

Permalink
moved db initialization (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReimarBauer authored Sep 29, 2023
1 parent f0a6659 commit 97a5baa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 7 additions & 0 deletions mslib/mscolab/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
"""

import os

from flask_migrate import Migrate

import mslib

from flask import Flask
from mslib.mscolab.conf import mscolab_settings
from flask_sqlalchemy import SQLAlchemy
from mslib.mswms.gallery_builder import STATIC_LOCATION
from mslib.utils import prefix_route

Expand Down Expand Up @@ -58,3 +62,6 @@
APP.config['MAIL_PASSWORD'] = getattr(mscolab_settings, "MAIL_PASSWORD", None)
APP.config['MAIL_USE_TLS'] = getattr(mscolab_settings, "MAIL_USE_TLS", None)
APP.config['MAIL_USE_SSL'] = getattr(mscolab_settings, "MAIL_USE_SSL", None)

db = SQLAlchemy(APP)
migrate = Migrate(APP, db, render_as_batch=True)
6 changes: 1 addition & 5 deletions mslib/mscolab/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@
import datetime
import logging
import jwt

from passlib.apps import custom_app_context as pwd_context
from flask_sqlalchemy import SQLAlchemy
from mslib.mscolab.app import APP
from mslib.mscolab.app import db
from mslib.mscolab.message_type import MessageType

db = SQLAlchemy(APP)


class User(db.Model):

Expand Down
4 changes: 1 addition & 3 deletions mslib/mscolab/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@
from flask import send_from_directory, abort, url_for
from flask_mail import Mail, Message
from flask_cors import CORS
from flask_migrate import Migrate
from flask_httpauth import HTTPBasicAuth
from validate_email import validate_email
from werkzeug.utils import secure_filename

from mslib.mscolab.conf import mscolab_settings
from mslib.mscolab.models import Change, MessageType, User, db
from mslib.mscolab.models import Change, MessageType, User
from mslib.mscolab.sockets_manager import setup_managers
from mslib.mscolab.utils import create_files, get_message_dict
from mslib.utils import conditional_decorator
Expand All @@ -56,7 +55,6 @@
APP = create_app(__name__)
mail = Mail(APP)
CORS(APP, origins=mscolab_settings.CORS_ORIGINS if hasattr(mscolab_settings, "CORS_ORIGINS") else ["*"])
migrate = Migrate(APP, db, render_as_batch=True)
auth = HTTPBasicAuth()


Expand Down

0 comments on commit 97a5baa

Please sign in to comment.