2018-01-01 21:54:03 +01:00
|
|
|
import os
|
2018-01-14 20:49:35 +01:00
|
|
|
|
2020-07-14 22:03:56 +02:00
|
|
|
from dramatiq.brokers.redis import RedisBroker
|
|
|
|
from dramatiq.brokers.stub import StubBroker
|
2018-01-01 21:54:03 +01:00
|
|
|
from flask import current_app
|
2020-09-16 18:58:11 +02:00
|
|
|
from sqlalchemy.pool import NullPool
|
2018-01-01 21:54:03 +01:00
|
|
|
|
2020-09-16 15:41:02 +02:00
|
|
|
if os.getenv('APP_SETTINGS') == 'fittrackee.config.TestingConfig':
|
2020-07-14 22:03:56 +02:00
|
|
|
broker = StubBroker
|
|
|
|
else:
|
|
|
|
broker = RedisBroker
|
|
|
|
|
2018-01-01 21:54:03 +01:00
|
|
|
|
2017-12-16 21:00:46 +01:00
|
|
|
class BaseConfig:
|
|
|
|
"""Base configuration"""
|
2019-08-28 13:25:39 +02:00
|
|
|
|
2017-12-16 21:00:46 +01:00
|
|
|
DEBUG = False
|
|
|
|
TESTING = False
|
|
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
|
|
|
BCRYPT_LOG_ROUNDS = 13
|
|
|
|
TOKEN_EXPIRATION_DAYS = 30
|
|
|
|
TOKEN_EXPIRATION_SECONDS = 0
|
2020-05-10 17:08:18 +02:00
|
|
|
PASSWORD_TOKEN_EXPIRATION_SECONDS = 3600
|
2020-09-16 18:58:11 +02:00
|
|
|
UPLOAD_FOLDER = os.path.join(
|
|
|
|
os.getenv('UPLOAD_FOLDER', current_app.root_path), 'uploads'
|
|
|
|
)
|
2018-01-01 21:54:03 +01:00
|
|
|
PICTURE_ALLOWED_EXTENSIONS = {'jpg', 'png', 'gif'}
|
2021-01-10 11:16:43 +01:00
|
|
|
WORKOUT_ALLOWED_EXTENSIONS = {'gpx', 'zip'}
|
2020-05-17 16:42:44 +02:00
|
|
|
TEMPLATES_FOLDER = os.path.join(current_app.root_path, 'email/templates')
|
|
|
|
UI_URL = os.environ.get('UI_URL')
|
|
|
|
EMAIL_URL = os.environ.get('EMAIL_URL')
|
|
|
|
SENDER_EMAIL = os.environ.get('SENDER_EMAIL')
|
2020-07-14 22:03:56 +02:00
|
|
|
DRAMATIQ_BROKER = broker
|
2020-09-16 13:01:15 +02:00
|
|
|
TILE_SERVER = {
|
|
|
|
'URL': os.environ.get(
|
|
|
|
'TILE_SERVER_URL',
|
|
|
|
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
|
|
),
|
|
|
|
'ATTRIBUTION': os.environ.get(
|
|
|
|
'MAP_ATTRIBUTION',
|
|
|
|
'© <a href="http://www.openstreetmap.org/copyright" '
|
|
|
|
'target="_blank" rel="noopener noreferrer">OpenStreetMap</a>'
|
|
|
|
' contributors',
|
|
|
|
),
|
|
|
|
}
|
2017-12-16 21:00:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
class DevelopmentConfig(BaseConfig):
|
|
|
|
"""Development configuration"""
|
2019-08-28 13:25:39 +02:00
|
|
|
|
2017-12-16 21:00:46 +01:00
|
|
|
DEBUG = True
|
2018-05-01 11:52:38 +02:00
|
|
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
|
2017-12-16 21:00:46 +01:00
|
|
|
SECRET_KEY = 'development key'
|
|
|
|
USERNAME = 'admin'
|
|
|
|
PASSWORD = 'default'
|
|
|
|
BCRYPT_LOG_ROUNDS = 4
|
2020-07-14 22:03:56 +02:00
|
|
|
DRAMATIQ_BROKER_URL = os.getenv('REDIS_URL', 'redis://')
|
2017-12-16 21:00:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestingConfig(BaseConfig):
|
2018-04-10 21:53:18 +02:00
|
|
|
"""Testing configuration"""
|
2019-08-28 13:25:39 +02:00
|
|
|
|
2017-12-16 21:00:46 +01:00
|
|
|
DEBUG = True
|
2018-04-09 22:09:58 +02:00
|
|
|
TESTING = True
|
2018-05-01 11:52:38 +02:00
|
|
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_TEST_URL')
|
2017-12-16 21:00:46 +01:00
|
|
|
SECRET_KEY = 'test key'
|
|
|
|
USERNAME = 'admin'
|
|
|
|
PASSWORD = 'default'
|
|
|
|
BCRYPT_LOG_ROUNDS = 4
|
|
|
|
TOKEN_EXPIRATION_DAYS = 0
|
|
|
|
TOKEN_EXPIRATION_SECONDS = 3
|
2020-05-17 16:42:44 +02:00
|
|
|
PASSWORD_TOKEN_EXPIRATION_SECONDS = 3
|
2020-05-02 10:39:43 +02:00
|
|
|
UPLOAD_FOLDER = '/tmp/fitTrackee/uploads'
|
2020-09-16 18:58:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ProductionConfig(BaseConfig):
|
|
|
|
"""Production configuration"""
|
|
|
|
|
|
|
|
DEBUG = False
|
|
|
|
# https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing-or-os-fork # noqa
|
|
|
|
SQLALCHEMY_ENGINE_OPTIONS = (
|
|
|
|
{'poolclass': NullPool}
|
2020-09-19 13:56:14 +02:00
|
|
|
if os.getenv('DATABASE_DISABLE_POOLING', False)
|
2020-09-16 18:58:11 +02:00
|
|
|
else {}
|
|
|
|
)
|
|
|
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
|
|
|
|
SECRET_KEY = os.getenv('APP_SECRET_KEY')
|
|
|
|
DRAMATIQ_BROKER_URL = os.getenv('REDIS_URL', 'redis://')
|