-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathsettings.py
More file actions
268 lines (221 loc) · 8.15 KB
/
Copy pathsettings.py
File metadata and controls
268 lines (221 loc) · 8.15 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
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
from pathlib import Path
import os
import django_heroku
from django.conf import settings
from dotenv import load_dotenv
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# load environment variables
load_dotenv()
# Quick-start development settings - unsuitable for production
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-=dei9kx=^q))zm#z-(_cwdii75e-4bsf5_7suo9ll&besz088u'
# from django.conf import settings
settings.configure()
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ["127.0.0.1", ".vercel.app", ".now.sh"]
# Application definition
INSTALLED_APPS = [
'adminactions',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
# App
'profile',
# App
'users',
# App
'qa',
# App
'notification',
# App
'review',
# App
'tagbadge',
# App
'help',
'taggit',
'crispy_forms',
'martor',
'simple_history',
# 'background_task',
'review.templatetags',
'tagbadge.tb_templatetags',
'online_users',
# 'debug_toolbar',
'tools',
]
MAX_ATTEMPTS = 1
SECURE_BROWSER_XSS_FILTER = True
CRISPY_TEMPLATE_PACK = 'bootstrap4'
MIDDLEWARE = [
'simple_history.middleware.HistoryRequestMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware', #add whitenoise
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'online_users.middleware.OnlineNowMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
]
ROOT_URLCONF = 'main.urls'
TEMPLATE_DIR = os.path.join(BASE_DIR,"templates")
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR],
'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',
'review.context_processors.reviewAnswer_cp',
'review.context_processors.returnTrue',
'review.context_processors.reviewQuestion_cp',
'review.context_processors.returnTrue_or_False',
'review.context_processors.reviewLateAnswer_cp',
'review.context_processors.returnLateReview_True_or_False',
'review.context_processors.reviewClosedQuestions',
'review.context_processors.returnTrue_or_FalseClosedQuestions',
'review.context_processors.reviewReOpenQuestion_sVotes',
'review.context_processors.returnTrue_or_FalseUnCloseQuestion_s',
'review.context_processors.reviewEditedPosts',
'review.context_processors.returnTrue_or_FalseEditPosts',
'review.context_processors.reviewLowQualityPosts',
'review.context_processors.returnTrue_or_FalseLowPosts',
'review.context_processors.reviewFlagPosts',
'review.context_processors.returnTrue_or_FalseFlagPosts',
'review.context_processors.reviewFlagComments',
'review.context_processors.returnTrue_or_FalseFlagComments',
'notification.context_processors.privNotificationViewer',
'notification.context_processors.notificationViewer',
'profile.context_processors.top_questions',
'profile.context_processors.count_all_bounties',
],
},
},
]
WSGI_APPLICATION = 'main.wsgi.application'
# DATABASES
"""
If you don't want to use postgresql then remove comment of sqlite's configuration and
comment in the postgresql configuration
"""
DATABASES = {
'default': {
'ENGINE': os.getenv("DB_ENGINE"),
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASSWORD"),
'HOST': os.getenv("DB_HOST"),
'PORT': os.getenv("DB_PORT"),
}
}
# 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',
},
]
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient"
},
"KEY_PREFIX": "example"
}
}
CACHE_TTL = 60 * 15
# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# os.path.join(BASE_DIR, "static", "static")
#MY SETTINGS FOR LOGIN.
LOGIN_URL = 'users:login_request'
# STATICFILES_DIRS = [
# os.path.join(BASE_DIR, 'static'),
# os.path.join(BASE_DIR, 'media'),
# ]
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Heroku setting
# Serving the statics through Whitenoise in Heroku
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Martor Configuration
MARTOR_THEME = 'bootstrap' # semantic
MARTOR_ENABLE_LABEL = True
MARTOR_ENABLE_CONFIGS = {
'emoji': 'true', # to enable/disable emoji icons.
'imgur': 'true', # to enable/disable imgur/custom uploader.
'mention': 'true', # to enable/disable mention
'jquery': 'true', # to include/revoke jquery (require for admin default django)
'living': 'true', # to enable/disable live updates in preview
'spellcheck': 'true', # to enable/disable spellcheck in form textareas
'hljs': 'true', # to enable/disable hljs highlighting in preview
}
MARTOR_TOOLBAR_BUTTONS = [
'bold', 'italic', 'horizontal', 'heading', 'pre-code',
'blockquote', 'unordered-list', 'ordered-list',
'link', 'image-link', 'image-upload', 'emoji',
'direct-mention', 'toggle-maximize', 'help'
]
CKEDITOR_JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'
CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_IMAGE_BACKEND = "pillow"
# django debug toolbar configuration
# INTERNAL_IPS = [
# '127.0.0.1',
# ]
# DEBUG_TOOLBAR_PANELS = [
# 'debug_toolbar.panels.history.HistoryPanel',
# 'debug_toolbar.panels.versions.VersionsPanel',
# 'debug_toolbar.panels.timer.TimerPanel',
# 'debug_toolbar.panels.settings.SettingsPanel',
# 'debug_toolbar.panels.headers.HeadersPanel',
# 'debug_toolbar.panels.request.RequestPanel',
# 'debug_toolbar.panels.sql.SQLPanel',
# 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
# 'debug_toolbar.panels.templates.TemplatesPanel',
# 'debug_toolbar.panels.cache.CachePanel',
# 'debug_toolbar.panels.signals.SignalsPanel',
# 'debug_toolbar.panels.logging.LoggingPanel',
# 'debug_toolbar.panels.redirects.RedirectsPanel',
# 'debug_toolbar.panels.profiling.ProfilingPanel',
# ]
# Heroku setting
django_heroku.settings(locals())