This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
73 lines (50 loc) · 2.38 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
import base64
basedir = os.path.abspath(os.path.dirname(__file__))
HOSTNAME = os.environ.get("APP_HOSTNAME", "review.hackership.org")
DEBUG = os.environ.get("PRODUCTION", False) is False
SECRET_KEY = os.environ.get("SECRET_KEY", "__DEV")
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL", 'sqlite:///{}'.format(os.path.join(basedir, 'app.db')))
if SQLALCHEMY_DATABASE_URI.startswith('postg'):
SQLALCHEMY_NATIVE_UNICODE = False
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
# Flask-Security, For Login-and Such
# see https://pythonhosted.org/Flask-Security/configuration.html
SECURITY_PASSWORD_HASH = "bcrypt"
SECURITY_PASSWORD_SALT = os.environ.get("SECURITY_PASSWORD_SALT", "__DEV")
SECURITY_EMAIL_SENDER = "no-reply@{}".format(HOSTNAME)
SECURITY_REGISTERABLE = False
SECURITY_SEND_REGISTER_EMAIL = False
SECURITY_DEFAULT_REMEMBER_ME = True
SECURITY_TRACKABLE = True
SECURITY_RECOVERABLE = True
SCHEMA_TOKEN = os.environ.get("SCHEMA_TOKEN", 'THINGY')
MAIL_SERVER = os.environ.get("MAIL_SERVER", "")
MAIL_PORT = int(os.environ.get("MAIL_PORT", 25))
MAIL_USERNAME = os.environ.get("MAIL_USERNAME", "")
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD", "")
MAIL_DEFAULT_SENDER = os.environ.get("MAIL_DEFAULT_SENDER", SECURITY_EMAIL_SENDER)
MAIL_SUPPRESS_SEND = DEBUG
GDATA_PRIVATE_EMAIL = os.environ.get("GDATA_PRIVATE_EMAIL", "")
GDATA_PRIVATE_KEY = base64.b64decode(os.environ.get("GDATA_PRIVATE_KEY", ""))
GDATA_CALENDAR_ID = os.environ.get("GDATA_CALENDAR_ID", "")
# CELERY Queue Manager
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_RESULT_BACKEND = "db+{}".format(SQLALCHEMY_DATABASE_URI)
CELERY_BROKER_URL = os.environ.get("REDIS_URL", 'sqla+sqlite:///{}'.format(os.path.join(basedir, 'broker.db')))
try:
from local_config import *
except ImportError:
pass
# CONSTRAINS to ensure we are not running with a bad Config
if not DEBUG:
if not MAIL_SERVER:
raise ValueError("You need to set the environment variable 'MAIL_SERVER'!")
if SECRET_KEY == "__DEV":
raise ValueError("You need to set the environment variable 'SECRET_KEY'!")
if SECURITY_PASSWORD_SALT == "__DEV":
raise ValueError("You need to set the environment variable 'SECURITY_PASSWORD_SALT'!")
if SCHEMA_TOKEN == "THINGY":
raise ValueError("You need to set the environment variable 'SCHEMA_TOKEN'!")