2018-02-23 23:34:06 +01:00
|
|
|
import os
|
2021-02-21 20:17:48 +01:00
|
|
|
from datetime import timedelta
|
2020-02-09 23:04:00 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
from local_config import LocalConfig
|
|
|
|
except ImportError:
|
|
|
|
print(" \033[92mWARNING: Local config not found\033[0m")
|
2021-01-12 17:34:50 +01:00
|
|
|
|
2022-05-05 20:31:26 +02:00
|
|
|
# The LocalConfig class serves a dual purpose and overrides settings in
|
|
|
|
# both V5Config and some fields of FlaskApplicationSettings. The first has
|
|
|
|
# defaults (DefaultConfig), but not the second, so we provide them here.
|
2020-02-09 23:10:02 +01:00
|
|
|
class LocalConfig():
|
2022-05-05 20:31:26 +02:00
|
|
|
FLASK_DEBUG = False
|
|
|
|
DB_NAME = "pcv5"
|
|
|
|
SECRET_KEY = "a-random-secret-key"
|
2020-02-09 23:04:00 +01:00
|
|
|
|
2022-05-05 20:31:26 +02:00
|
|
|
#---
|
|
|
|
# Flask configuration
|
|
|
|
#---
|
|
|
|
|
|
|
|
class FlaskApplicationSettings(object):
|
|
|
|
"""
|
|
|
|
This object specifies the settings for the Flask application. All the keys
|
|
|
|
and values are predefined by Flask.
|
|
|
|
|
|
|
|
See: https://flask.palletsprojects.com/en/2.1.x/config/
|
|
|
|
"""
|
|
|
|
|
|
|
|
DEBUG = os.environ.get("FLASK_DEBUG") or LocalConfig.FLASK_DEBUG
|
2019-06-05 11:35:54 +02:00
|
|
|
|
2019-12-05 22:49:18 +01:00
|
|
|
SECRET_KEY = os.environ.get('SECRET_KEY') or LocalConfig.SECRET_KEY
|
2018-02-23 23:34:06 +01:00
|
|
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
2019-12-05 22:49:18 +01:00
|
|
|
'postgresql+psycopg2://' + os.environ.get('USER') + ':@/' \
|
|
|
|
+ LocalConfig.DB_NAME
|
2018-02-23 23:34:06 +01:00
|
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
2019-06-05 11:35:54 +02:00
|
|
|
|
2020-07-21 21:06:00 +02:00
|
|
|
MAIL_DEFAULT_SENDER = "noreply@v5.planet-casio.com"
|
|
|
|
MAIL_SUPPRESS_SEND = None
|
|
|
|
|
2020-10-30 14:05:34 +01:00
|
|
|
# Only send cookies over HTTPS connections (use only if HTTPS is enabled)
|
|
|
|
SESSION_COOKIE_SECURE = True
|
|
|
|
# Only send cookies in requests, do not expose them to Javascript
|
|
|
|
SESSION_COOKIE_HTTPONLY = True
|
|
|
|
# Do not attach cookies to cross-origin requests
|
|
|
|
SESSION_COOKIE_SAMESITE = "Lax"
|
2019-02-03 15:00:37 +01:00
|
|
|
|
2022-05-05 20:31:26 +02:00
|
|
|
#---
|
|
|
|
# v5 configuration
|
|
|
|
#---
|
2021-01-12 17:34:50 +01:00
|
|
|
|
2020-02-09 23:04:00 +01:00
|
|
|
class DefaultConfig(object):
|
2020-07-21 21:06:00 +02:00
|
|
|
# Domain
|
|
|
|
DOMAIN = "v5.planet-casio.com"
|
2020-02-09 23:04:00 +01:00
|
|
|
# Database name
|
|
|
|
DB_NAME = "pcv5"
|
|
|
|
# LDAP usage
|
|
|
|
USE_LDAP = False
|
|
|
|
# LDAP configuration
|
|
|
|
LDAP_PASSWORD = "openldap"
|
2020-08-25 23:05:54 +02:00
|
|
|
LDAP_ROOT = "o=planet-casio"
|
|
|
|
LDAP_ENV = "o=prod"
|
2020-02-09 23:04:00 +01:00
|
|
|
# Secret key used to authenticate tokens. **USE YOURS!**
|
2020-02-09 23:15:51 +01:00
|
|
|
SECRET_KEY = "a-random-secret-key"
|
2020-07-26 16:50:07 +02:00
|
|
|
# Uploaded data folder
|
|
|
|
DATA_FOLDER = '/var/www/uploads'
|
2020-07-17 23:49:04 +02:00
|
|
|
# Enable guest post
|
|
|
|
ENABLE_GUEST_POST = True
|
2020-07-21 21:06:00 +02:00
|
|
|
# Disable email confimation
|
|
|
|
ENABLE_EMAIL_CONFIRMATION = True
|
|
|
|
# Send emails
|
|
|
|
SEND_MAILS = True
|
2020-11-11 13:26:45 +01:00
|
|
|
# GLaDOS configuration
|
|
|
|
GLADOS_HOST = "127.0.0.1"
|
|
|
|
GLADOS_PORT = 5555
|
2021-02-21 20:17:48 +01:00
|
|
|
# Time before trigerring the necropost alert
|
|
|
|
NECROPOST_LIMIT = timedelta(days=31)
|
2021-07-07 18:42:17 +02:00
|
|
|
# Acceptable page loading time; longer generation is reported to devs. This
|
|
|
|
# is computed in the page header, so it doesn't account for most of the
|
|
|
|
# template generation.
|
|
|
|
SLOW_REQUEST_THRESHOLD = 0.400 # s
|
2021-01-12 17:34:50 +01:00
|
|
|
|
2020-02-09 23:04:00 +01:00
|
|
|
|
|
|
|
class V5Config(LocalConfig, DefaultConfig):
|
2022-05-05 20:31:26 +02:00
|
|
|
"""
|
|
|
|
This object holds the settings for the v5 code. Each parameter has the
|
|
|
|
value specified in LocalConfig (if any), and defaults to the value set in
|
|
|
|
DefaultConfig.
|
|
|
|
"""
|
2020-02-09 23:04:00 +01:00
|
|
|
pass
|