-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathsettings.py
292 lines (241 loc) · 7.84 KB
/
settings.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
import os
import sys
from pathlib import Path
from datetime import datetime as dt
from django.utils.translation import gettext_lazy as _
from decouple import config, Csv
from dj_database_url import parse as dburl
from crm.settings import * # NOQA
from massmail.settings import * # NOQA
from common.settings import * # NOQA
from tasks.settings import * # NOQA
from voip.settings import * # NOQA
# ---- Django settings ---- #
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(__file__).resolve().parent.parent
# SECURITY WARNING: keep the secret key used in production secret!
# To get new value of key use code:
# from django.core.management.utils import get_random_secret_key
# print(get_random_secret_key())
SECRET_KEY = config('SECRET_KEY')
# Add your hosts to the list.
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[], cast=Csv())
# Database
default_dburl = 'sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3') # Use sqlite if database is not setted in .env
DATABASES = {
'default': config('DATABASE_URL', default=default_dburl, cast=dburl) ## Configure .env with DATABASE_URL=<user>:<pass>@<host>:<port>/<dbname>
}
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_PORT = config('EMAIL_PORT')
EMAIL_SUBJECT_PREFIX = 'CRM: '
EMAIL_USE_TLS = True
SERVER_EMAIL = config('SERVER_EMAIL')
DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL')
ADMINS = [(config('ADMIN_NAME'), config('ADMIN_EMAIL'))] # specify admin
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)
FORMS_URLFIELD_ASSUME_HTTPS = True
# Internationalization
LANGUAGE_CODE = config('LANGUAGE_CODE')
LANGUAGES = [
('ar', 'Arabic'),
('cs', 'Czech'),
('de', 'German'),
('el', 'Greek'),
('en', 'English'),
('es', 'Spanish'),
('fr', 'French'),
('he', 'Hebrew'),
('hi', 'Hindi'),
('id', 'Indonesian'),
('it', 'Italian'),
('ja', 'Japanese'),
('ko', 'Korean'),
('nl', 'Nederlands'),
('pl', 'Polish'),
('pt-br', 'Portuguese'),
('ro', 'Romanian'),
('ru', 'Russian'),
('tr', 'Turkish'),
('uk', 'Ukrainian'),
('vi', 'Vietnamese'),
('zh-hans', 'Chinese'),
]
TIME_ZONE = 'UTC' # specify your time zone
USE_I18N = True
USE_TZ = True
LOCALE_PATHS = [
BASE_DIR / 'locale',
]
LOGIN_URL = '/admin/login/'
# Application definition
INSTALLED_APPS = [
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crm.apps.CrmConfig',
'massmail.apps.MassmailConfig',
'analytics.apps.AnalyticsConfig',
'help',
'tasks.apps.TasksConfig',
'chat.apps.ChatConfig',
'voip',
'common.apps.CommonConfig',
'settings'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'common.utils.usermiddleware.UserMiddleware'
]
ROOT_URLCONF = 'webcrm.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'webcrm.wsgi.application'
# Password validation
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Static files (CSS, JavaScript, Images)
STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / 'static'
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / 'media'
FIXTURE_DIRS = ['tests/fixtures']
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
SITE_ID = 1
SECURE_HSTS_SECONDS = 0 # set to 31536000 for production server
# Set all the following to True for production server
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
SECURE_HSTS_PRELOAD = False
# ---- CRM settings ---- #
# For more security, replace the url prefixes
# with your own unique value.
SECRET_CRM_PREFIX = config('SECRET_CRM_PREFIX')
SECRET_ADMIN_PREFIX = config('SECRET_ADMIN_PREFIX')
SECRET_LOGIN_PREFIX = config('SECRET_LOGIN_PREFIX')
# Specify ip of host to avoid importing emails sent by CRM
CRM_IP = config('CRM_IP')
#CRM_REPLY_TO = ["'Do not reply' <[email protected]>"]
CRM_REPLY_TO = config('CRM_REPLY_TO', default=[], cast=Csv())
# List of addresses to which users are not allowed to send mail.
NOT_ALLOWED_EMAILS = []
# List of applications on the main page and in the left sidebar.
APP_ON_INDEX_PAGE = [
'tasks', 'crm', 'analytics',
'massmail', 'common', 'settings'
]
MODEL_ON_INDEX_PAGE = {
'tasks': {
'app_model_list': ['Task', 'Memo']
},
'crm': {
'app_model_list': [
'Request', 'Deal', 'Lead', 'Company',
'CrmEmail', 'Payment', 'Shipment'
]
},
'analytics': {
'app_model_list': [
'IncomeStat', 'RequestStat'
]
},
'massmail': {
'app_model_list': [
'MailingOut', 'EmlMessage'
]
},
'common': {
'app_model_list': [
'UserProfile', 'Reminder'
]
},
'settings': {
'app_model_list': [
'PublicEmailDomain', 'StopPhrase'
]
}
}
# Country VAT value
VAT = 0 # %
# 2-Step Verification Credentials for Google Accounts.
# OAuth 2.0
CLIENT_ID = config('CLIENT_ID')
CLIENT_SECRET = config('CLIENT_SECRET')
OAUTH2_DATA = {
'smtp.gmail.com': {
'scope': "https://mail.google.com/",
'accounts_base_url': 'https://accounts.google.com',
'auth_command': 'o/oauth2/auth',
'token_command': 'o/oauth2/token',
}
}
# Hardcoded dummy redirect URI for non-web apps.
REDIRECT_URI = config('REDIRECT_URI')
# Credentials for Google reCAPTCHA.
GOOGLE_RECAPTCHA_SITE_KEY = config('GOOGLE_RECAPTCHA_SITE_KEY')
GOOGLE_RECAPTCHA_SECRET_KEY = config('GOOGLE_RECAPTCHA_SECRET_KEY')
GEOIP = False
GEOIP_PATH = MEDIA_ROOT / 'geodb'
# For user profile list
SHOW_USER_CURRENT_TIME_ZONE = False
NO_NAME_STR = _('Untitled')
# For automated getting currency exchange rate
LOAD_EXCHANGE_RATE = False
LOADING_EXCHANGE_RATE_TIME = "6:30"
LOAD_RATE_BACKEND = "" # "crm.backends.<specify_backend>.<specify_class>"
# Ability to mark payments through a representation
MARK_PAYMENTS_THROUGH_REP = False
# Site headers
SITE_TITLE = config('SITE_TITLE')
ADMIN_HEADER = config('ADMIN_HEADER')
ADMIN_TITLE = config('ADMIN_TITLE')
INDEX_TITLE = _('Main Menu')
# This is copyright information. Please don't change it!
COPYRIGHT_STRING = f"Django-CRM. Copyright (c) {dt.now().year}"
PROJECT_NAME = "Django-CRM"
PROJECT_SITE = "https://github.com/DjangoCRM/django-crm/"
TESTING = sys.argv[1:2] == ['test']
if TESTING:
SECURE_SSL_REDIRECT = False
LANGUAGE_CODE = 'en'
LANGUAGES = [('en', ''), ('uk', '')]