-
Notifications
You must be signed in to change notification settings - Fork 37
/
settings.py
411 lines (345 loc) · 10.8 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
"""
Django settings for bitpoll project.
Generated by 'django-admin startproject' using Django 1.9.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from django.contrib import messages
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = os.path.join(ROOT_DIR, '_media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = os.path.join(ROOT_DIR, '_static')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
ALLOWED_HOSTS = []
TEMPLATE_ALLOWABLE_SETTINGS_VALUES = [
'ALLOW_CUSTOM_SLUGS',
'SITE_NAME',
'DEBUG',
'DEFAULT_RANDOM_SLUG',
'BASE_URL',
'HOME_URL',
'HOME_URL_NAME',
'IMPRINT_TEXT',
'IMPRINT_URL',
'TIME_ZONE',
'REGISTER_ENABLED',
'MAIL_SIGNATURE',
'GROUP_MANAGEMENT',
'PUBLIC_POLLS',
'CALENDAR_ENABLED',
'POLL_CREATION_REQUIRES_LOGIN',
'POLL_CREATION_ACCOUNT_WEBSITE',
'POLL_CREATION_ACCOUNT_NAME',
'OPENID_ENABLED',
]
LOGIN_REDIRECT_URL = "/"
LOGIN_URL = '/login/'
SITE_NAME = 'Bitpoll'
BASE_URL = 'https://bitpoll.mafiasi.de'
# Application definition
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django_simple_csp',
'markdownify',
'widget_tweaks',
'pipeline',
'bitpoll.poll.apps.BitpollConfig',
'bitpoll.base',
'bitpoll.invitations',
'bitpoll.registration',
'bitpoll.groups',
'bitpoll.caldav',
'django.contrib.admin',
'friendlytagloader',
'encrypted_model_fields',
'django_token_bucket',
]
MIDDLEWARE = [
'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',
'django.middleware.locale.LocaleMiddleware',
'django_simple_csp.middleware.csp.CSPMiddleware',
'pipeline.middleware.MinifyHTMLMiddleware',
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
]
STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'
PIPELINE = {
'STYLESHEETS': {
'base': {
'source_filenames': (
'fontawesome/css/fontawesome.css',
'fontawesome/css/solid.css',
'fontawesome/css/v4-shims.css',
'scss/main.scss',
'scss/poll.scss'
),
'output_filename': 'css/base.css',
},
'base_print': {
'source_filenames': (
'css/print.css',
),
'output_filename': 'css/base_print.css',
'extra_context': {
'media': 'print',
},
},
'base_screen': {
'source_filenames': (
'css/bootstrap.css',
'css/bootstrap-theme.css',
# 'css/jquery-range.css', # this belongs to commented out JS class
'scss/form.scss',
'scss/action.scss',
'scss/slider.scss',
'scss/timeinput.scss',
'css/jquery.datetimepicker.css',
),
'output_filename': 'css/base_screen.css',
'extra_context': {
'media': 'screen,projection',
},
},
'poll_edit': {
'source_filenames': (
'scss/calendar.scss',
'scss/iconpreview.scss',
),
'output_filename': 'css/poll_edit.css',
'extra_context': {
'media': 'screen,projection',
},
},
},
'JAVASCRIPT': {
'base': {
'source_filenames': (
'js/lib/jquery-3.2.1.js',
'js/lib/bootstrap.js',
),
'output_filename': 'js/base.js',
},
'create_poll': {
'source_filenames': (
'js/create.js',
'js/slug.js',
),
'output_filename': 'js/index.js',
},
'poll_edit': {
'source_filenames': (
'js/poll_edit_universal_choices.js',
'js/poll_edit_choices.js',
),
'output_filename': 'js/poll_edit.js',
},
'base_late': {
'source_filenames': (
#'js/lib/jquery-range.min.js', # TODO: is this needet for the numeric polls?
'js/lib/moment-with-locales.min.js',
'js/lib/mousetrap.min.js',
'js/main.js',
'js/util.js',
'js/custom-select.jquery.js',
'js/common.js',
'js/slider.js',
'js/vote.js',
'js/lib/jquery.datetimepicker.full.min.js',
),
'output_filename': 'js/base_late.js',
},
},
'COMPILERS': (
'libsasscompiler.LibSassCompiler',
),
'CSS_COMPRESSOR': 'pipeline.compressors.NoopCompressor', # TODO
'JS_COMPRESSOR': 'pipeline.compressors.NoopCompressor', # TODO
}
PIPELINE_ENABLED = False # todo uglfyer mal ansehen
ROOT_URLCONF = 'bitpoll.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(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 = 'bitpoll.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'TIMEOUT': 60 * 30,
'OPTIONS': {
'MAX_ENTRIES': 1000
}
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
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',
},
]
# User Model
AUTH_USER_MODEL = 'base.BitpollUser'
CSRF_COOKIE_HTTPONLY = True
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'de-de'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_PRECOMPILER_ROOT = STATIC_ROOT
SASS_PRECISION = 8
ALLOW_CUSTOM_SLUGS = True
DEFAULT_RANDOM_SLUG = 'true' # this value is an JS true/false
MESSAGE_TAGS = {
messages.DEBUG: 'debug',
messages.INFO: 'info',
messages.SUCCESS: 'success',
messages.WARNING: 'warning',
messages.ERROR: 'danger',
}
# Url to the Base Homepage and Text on the Link, leave empty to not use this option
HOME_URL = "https://example.com"
HOME_URL_NAME = "Dashboard"
# Test mail functionality by printing mails to console:
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# if the imprint URL is not empty use it as an link to the imprint, else use IMPRINT_TEXT
IMPRINT_URL = ""
IMPRINT_TEXT = """
<h1>Impressum</h1>
<p>Text goes here</p>
"""
LOCALE_PATHS = (os.path.join(ROOT_DIR, 'locale'), )
LANGUAGES = (
('de', 'Deutsch'),
('en', 'English'),
('it', 'Italiano'),
)
REGISTER_ENABLED = True
GROUP_MANAGEMENT = REGISTER_ENABLED
POLL_CREATION_REQUIRES_LOGIN = False
POLL_CREATION_ACCOUNT_WEBSITE = "https://example.org"
POLL_CREATION_ACCOUNT_NAME = "Example"
CSP_REPORT_ONLY = True
CSP_REPORT_URL = ""
MAIL_SIGNATURE = "Bitpoll Team"
TEAM_EMAIL = "mail@example.com"
PUBLIC_POLLS = True
CALENDAR_ENABLED = True
CALENDAR_MAX_TOKENS = 2
CALENDAR_FILL_RATE = 500
#See https://django-markdownify.readthedocs.io/en/latest/settings.html
MARKDOWNIFY = {
"default": {
"WHITELIST_TAGS": [
'a',
'abbr',
'acronym',
'b',
'blockquote',
'em',
'i',
'li',
'ol',
'p',
'strong',
'ul',
'h1',
'h2',
'h3',
],
"WHITELIST_ATTRS": [
'href',
# 'src',
# 'alt',
],
"WHITELIST_PROTOCOLS": [
'https',
],
"WHITELIST_STYLES": [
# 'color',
# 'font-weight',
],
"LINKIFY_TEXT": {
"PARSE_URLS": True,
# Next key/value-pairs only have effect if "PARSE_URLS" is True
"PARSE_EMAIL": False,
"CALLBACKS": [],
"SKIP_TAGS": [],
}
}
}
# The root dir bitpoll appears to be in from the web, as configured in the webserver
URL_PREFIX = ''
ANTI_SPAM_CHALLENGE_TTL = 60 * 60 * 24 * 7 # Defaults to 7 days
OPENID_ENABLED = False
from .settings_local import *
INSTALLED_APPS += INSTALLED_APPS_LOCAL
if "MIDDLEWARE_LOCAL" in locals():
MIDDLEWARE += MIDDLEWARE_LOCAL
PIPELINE.update(PIPELINE_LOCAL)