Cleanup. Move old controller, removed unused code.

This commit is contained in:
Ferdinand Thiessen 2020-09-07 18:11:38 +02:00
parent 7caaea71a7
commit bf33529bf1
30 changed files with 14 additions and 46 deletions

View File

@ -11,10 +11,10 @@ from pathlib import Path
from logging.config import dictConfig from logging.config import dictConfig
from werkzeug.local import LocalProxy from werkzeug.local import LocalProxy
__version__ = pkg_resources.get_distribution('flaschengeist').version
_module_path = Path(__file__).parent _module_path = Path(__file__).parent
logger = LocalProxy(lambda: logging.getLogger(__name__)) logger = LocalProxy(lambda: logging.getLogger(__name__))
__version__ = pkg_resources.get_distribution('flaschengeist').version
with (_module_path / 'logging.yml').open(mode='rb') as file: with (_module_path / 'logging.yml').open(mode='rb') as file:
config = yaml.safe_load(file.read()) config = yaml.safe_load(file.read())

View File

@ -1,9 +1,8 @@
from datetime import datetime
import pkg_resources import pkg_resources
from flask import Flask from flask import Flask
from flask.json import JSONEncoder, jsonify
from flask_cors import CORS from flask_cors import CORS
from datetime import datetime
from flask.json import JSONEncoder, jsonify
from werkzeug.exceptions import HTTPException from werkzeug.exceptions import HTTPException
from . import logger from . import logger

View File

@ -33,7 +33,7 @@ CRYPT = SSL/STARTLS
# Configuration of plugins # # Configuration of plugins #
############################ ############################
[geruecht] [geruecht]
enable = true enabled = true
[schubu] [schubu]
enable = false enabled = false

View File

@ -19,34 +19,10 @@ handlers:
class: logging.handlers.WatchedFileHandler class: logging.handlers.WatchedFileHandler
level: DEBUG level: DEBUG
formatter: debug formatter: debug
filename: geruecht/log/debug/debug.log filename: flaschengeist/log/debug/debug.log
encoding: utf8
credit:
class: logging.handlers.WatchedFileHandler
level: INFO
formatter: simple
filename: geruecht/log/info/geruecht.log
encoding: utf8
jobs:
class: logging.handlers.WatchedFileHandler
level: INFO
formatter: simple
filename: geruecht/log/info/jobs.log
encoding: utf8 encoding: utf8
loggers: loggers:
credit_logger:
level: INFO
handlers: [credit]
propagate: no
jobs_logger:
level: INFO
handlers: [jobs]
propagate: no
werkzeug: werkzeug:
level: WARNING level: WARNING

View File

@ -1,4 +1,4 @@
from ..mainController import Singleton from flaschengeist.modules.geruecht.mainController import Singleton
from geruecht import db from geruecht import db
from ..databaseController import dbUserController, dbCreditListController, dbJobKindController, dbPricelistController, dbWorkerController, dbWorkgroupController, dbJobInviteController, dbJobRequesController, dbAccessTokenController, dbRegistrationController, dbFreeDrinkListConfigController from ..databaseController import dbUserController, dbCreditListController, dbJobKindController, dbPricelistController, dbWorkerController, dbWorkgroupController, dbJobInviteController, dbJobRequesController, dbAccessTokenController, dbRegistrationController, dbFreeDrinkListConfigController
from geruecht.exceptions import DatabaseExecption from geruecht.exceptions import DatabaseExecption

View File

@ -1,7 +1,7 @@
from .. import Singleton, userController from flaschengeist.system.controller import Singleton, userController
from ...models.user import User from flaschengeist.system.models.user import User
from datetime import datetime, timedelta from datetime import datetime, timedelta
from ...database import db from flaschengeist.system.database import db
from flask import current_app from flask import current_app
from werkzeug.local import LocalProxy from werkzeug.local import LocalProxy
logger = LocalProxy(lambda: current_app.logger) logger = LocalProxy(lambda: current_app.logger)

View File

@ -18,6 +18,7 @@ if 'FLASCHENGEIST_CONF' in os.environ:
for loc in paths: for loc in paths:
try: try:
with (loc/"flaschengeist.cfg").open() as source: with (loc/"flaschengeist.cfg").open() as source:
logger.info("Reading config file from >{}<".format(loc))
config.read_file(source) config.read_file(source)
except IOError: except IOError:
pass pass
@ -47,6 +48,8 @@ def configure_app(app):
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
if config.has_option("FLASCHENGEIST", "ROOT"): if config.has_option("FLASCHENGEIST", "ROOT"):
logger.debug("Setting application root to >{}<".format(config["FLASCHENGEIST"]["ROOT"]))
app.config["APPLICATION_ROOT"] = config["FLASCHENGEIST"]["ROOT"] app.config["APPLICATION_ROOT"] = config["FLASCHENGEIST"]["ROOT"]
if config.getboolean("FLASCHENGEIST", "PROXY", fallback=False): if config.getboolean("FLASCHENGEIST", "PROXY", fallback=False):
logger.debug("Fixing wsgi_app for using behind a proxy server")
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1) app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)

View File

@ -1,5 +1,5 @@
from functools import wraps from functools import wraps
from flask import request, jsonify from flask import request
from werkzeug.exceptions import Unauthorized from werkzeug.exceptions import Unauthorized
from flaschengeist import logger from flaschengeist import logger
@ -16,7 +16,6 @@ def login_required(**kwargs):
@wraps(func) @wraps(func)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
token = request.headers.get('Token') token = request.headers.get('Token')
logger.debug("token is {{ {} }}".format(token))
access_token = ac_controller.validate_token(token, request.user_agent, roles) access_token = ac_controller.validate_token(token, request.user_agent, roles)
if access_token: if access_token:
kwargs['access_token'] = access_token kwargs['access_token'] = access_token

View File

@ -1,9 +0,0 @@
class PermissionDenied(Exception):
def __init__(self, message=None):
if not message:
message = "PermissionDenied"
super().__init__(message)
class UsernameExistDB(Exception):
pass