-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
121 lines (91 loc) · 4.08 KB
/
config.py
File metadata and controls
121 lines (91 loc) · 4.08 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import os
from logging import FileHandler, Formatter
from logging.config import dictConfig
fileHandler = FileHandler("monolith/monolith.log", encoding="utf-8")
fileHandler.setFormatter(
Formatter("[%(asctime)s] %(levelname)s in %(module)s: %(message)s")
)
class Config:
MAX_CONTENT_LENGTH = 1024 * 1024
UPLOAD_EXTENSIONS = [".jpg", ".png", ".gif"]
UPLOAD_PATH = "uploads"
DROPZONE_ALLOWED_FILE_CUSTOM = True
DROPZONE_ALLOWED_FILE_TYPE = ".png, .jpg, .jpeg"
DROPZONE_MAX_FILE_SIZE = 2
DROPZONE_MAX_FILES = 30
DROPZONE_UPLOAD_MULTIPLE = True
DROPZONE_UPLOAD_ON_CLICK = True
# https://avatars.dicebear.com/api/avataaars/roma%20molesta.svg
AVATAR_PROVIDER = "https://avatars.dicebear.com/api/avataaars/{seed}.svg"
SECRET_KEY = os.environ.get("SECRET_KEY") or "top secret"
WTF_CSRF_SECRET_KEY = os.environ.get("WTF_CSRF_SECRET_KEY") or "top secret CSRF"
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URI") or "sqlite:///gooutsafe.db"
SQLALCHEMY_TRACK_MODIFICATIONS = False
MAIL_SERVER = os.environ.get("MAIL_SERVER") or "localhost"
MAIL_PORT = os.environ.get("MAIL_PORT") or 8025
MAIL_USE_TLS = os.environ.get("MAIL_USE_TLS") or False
MAIL_USERNAME = os.environ.get("MAIL_USERNAME") or None
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD") or None
MAIL_SENDER = os.environ.get("MAIL_SENDER") or "no-reply@gooutsafe.com"
REDIS_URL = os.environ.get("REDIS_URL") or "redis://:password@localhost:6379/1"
CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL") or "redis://redis:6379/0"
CELERY_RESULT_BACKEND = (
os.environ.get("CELERY_RESULT_BACKEND") or "redis://redis:6379/0"
)
CELERY_TASKS = ["monolith.services.background.tasks"]
ELASTICSEARCH_URL = os.environ.get("ELASTICSEARCH_URL")
DEBUG_TB_INTERCEPT_REDIRECTS = False
FLASK_PROFILER_ADMIN = os.environ.get("FLASK_PROFILER_ADMIN") or "admin"
FLASK_PROFILER_PASSWORD = os.environ.get("FLASK_PROFILER_PASSWORD") or "password"
FLASK_PROFILER = {
"enabled": True,
"storage": {"engine": "sqlite"},
"basicAuth": {
"enabled": True,
"username": FLASK_PROFILER_ADMIN,
"password": FLASK_PROFILER_PASSWORD,
},
"ignore": ["^/static/.*"],
}
@staticmethod
def init_app(app):
pass
class ProductionConfig(Config):
@staticmethod
def init_app(app):
app.logger.addHandler(fileHandler)
class DevelopmentConfig(Config):
DEBUG = True
@staticmethod
def init_app(app):
from flask_debugtoolbar import DebugToolbarExtension
app.debug = True
app.logger.addHandler(fileHandler)
DebugToolbarExtension(app)
class TestingConfig(Config):
TESTING = True
WTF_CSRF_ENABLED = False
SQLALCHEMY_DATABASE_URI = (
os.environ.get("TEST_DATABASE_URL") or "sqlite:///gooutsafe_test.db"
)
class DockerConfig(ProductionConfig):
@classmethod
def init_app(cls, app):
ProductionConfig.init_app(app)
# log to stderr
import logging
from logging import StreamHandler
file_handler = StreamHandler()
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
config = {
"production": ProductionConfig,
"development": DevelopmentConfig,
"testing": TestingConfig,
"docker": DockerConfig,
"default": DevelopmentConfig,
}
mail_body_covid_19_mark = "Hey {},\nIn date {}, the health authority {} marked you positive to Covid-19. Contact your personal doctor to protect your health and that of others."
mail_body_covid_19_contact = "Hey {},\nIn date {}, while you were at restaurant {}, you could have been in contact with a Covid-19 case. Contact your personal doctor to protect your health and that of others."
mail_body_covid_19_operator_alert = "Hey {},\nIn date {}, at your restaurant {}, a Covid-19 case had a booking. Execute as soon as possible the health protocols."
mail_body_covid_19_operator_booking_alert = "Hey {},\nYou have a booking of a Covid-19 positive case, at your restaurant {}. The reservation ID is {} at table {}."