-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
141 lines (116 loc) · 3.84 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
import production_settings
BASEDIR = os.path.abspath(os.path.dirname(__file__))
class Config:
DEBUG = False
TESTING = False
SECRET_KEY = 'im!mx2m(69)b^7n3j!yi)k!a7n(^09=^&*+pnan78hl^%_yp4u'
CSRF = True
CSRF_SECRET = 'im!mx2m(69)b^7n3j!yi)k!a7n(^09=^&*+pnan78hl^%_yp4u'
JSONIFY_PRETTYPRINT_REGULAR = False
UPLOAD_FOLDER = os.path.join(BASEDIR, 'media')
IMG_MIMES = {
'image/jpeg',
'image/png',
'image/gif',
}
DOC_MIMES = {
'application/vnd.openxmlformats-officedocument'
'.wordprocessingml.document', # .docx
'application/msword', # .doc
'application/pdf', # .pdf
'text/plain', # .txt
'application/vnd.openxmlformats-officedocument'
'.presentationml.presentation', # .pptx
'application/vnd.ms-powerpoint', # .ppt
'application/rtf', # .rtf
}
ALLOWED_MIMES = IMG_MIMES | DOC_MIMES
MAX_CONTENT_LENGTH = 15 * 1024 * 1024
FIXTURES_DIR = os.path.join(BASEDIR, 'fixtures')
# Celery
CELERY_IMPORTS = (
"project.tasks.mail",
"project.tasks.uploads",
)
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_BACKEND_URL = CELERY_BROKER_URL
# Email
MAIL_SERVER = 'smtp.yandex.ru'
MAIL_PORT = 465
MAIL_USE_SSL = True
MAILS_TO_SEND = ['hrportal@yandex.ru']
MAIL_USERNAME = 'hrportal@yandex.ru'
MAIL_PASSWORD = 'useaverystrongpasswordLuke'
MAIL_DEFAULT_SENDER = 'hrportal@yandex.ru'
# Logger configuration
LOG_CONFIG = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'INFO',
'formatter': 'detailed',
'stream': 'ext://sys.stdout',
},
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'INFO',
'formatter': 'detailed',
'filename': '/tmp/junk.log',
'mode': 'a',
'maxBytes': 10485760,
'backupCount': 5,
},
},
'formatters': {
'detailed': {
'format': '%(asctime)s %(module)-17s line:%(lineno)-4d '
'%(levelname)-8s %(message)s',
},
'email': {
'format': 'Timestamp: %(asctime)s\nModule: %(module)s\n'
'Line: %(lineno)d\nMessage: %(message)s',
},
},
'loggers': {
'extensive': {
'level': 'DEBUG',
'handlers': [
'file',
],
},
},
'root': {
'level': 'INFO',
'handlers': [
'console',
]
}
}
class ProductionConfig(Config):
# Database
SQLALCHEMY_DATABASE_URI = production_settings.SQLALCHEMY_DATABASE_URI
UPLOAD_FOLDER = production_settings.UPLOAD_FOLDER
# Celery
CELERY_BROKER_URL = production_settings.CELERY_BROKER_URL
CELERY_BACKEND_URL = production_settings.CELERY_BACKEND_URL
# Email
MAIL_SERVER = production_settings.MAIL_SERVER
MAIL_PORT = production_settings.MAIL_PORT
MAIL_USE_SSL = production_settings.MAIL_USE_SSL
MAIL_USERNAME = getattr(production_settings, "MAIL_USERNAME", None)
MAIL_PASSWORD = getattr(production_settings, "MAIL_PASSWORD", None)
MAIL_DEFAULT_SENDER = production_settings.MAIL_DEFAULT_SENDER
MAILS_TO_SEND = production_settings.MAILS_TO_SEND
class DevelopmentConfig(Config):
# Flask
DEBUG = True
DEVELOPMENT = True
SQLALCHEMY_ECHO = True
# Database
SQLALCHEMY_DATABASE_URI = 'postgresql://root:qwerty@localhost/hrportal'
class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite://'