|
@@ -0,0 +1,253 @@
|
|
1
|
+"""
|
|
2
|
+Django settings for this project.
|
|
3
|
+
|
|
4
|
+Generated by 'django-admin startproject' using Django 2.2.3.
|
|
5
|
+
|
|
6
|
+For more information on this file, see
|
|
7
|
+https://docs.djangoproject.com/en/2.2/topics/settings/
|
|
8
|
+
|
|
9
|
+For the full list of settings and their values, see
|
|
10
|
+https://docs.djangoproject.com/en/2.2/ref/settings/
|
|
11
|
+"""
|
|
12
|
+
|
|
13
|
+try:
|
|
14
|
+ from config import config
|
|
15
|
+ # required keys: SECRET_KEY
|
|
16
|
+ # optional keys: ALLOWED_HOSTS, DEFAULT_THEME, ITEM_ROOT, THUMBNAIL_SIZES, WEBNAIL_SIZES
|
|
17
|
+except ImportError:
|
|
18
|
+ config = {}
|
|
19
|
+import os
|
|
20
|
+import random
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
24
|
+#
|
|
25
|
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+# Quick-start development settings - unsuitable for production
|
|
29
|
+# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
|
30
|
+
|
|
31
|
+# SECURITY WARNING: keep the secret key used in production secret!
|
|
32
|
+#
|
|
33
|
+try:
|
|
34
|
+ SECRET_KEY = config['SECRET_KEY']
|
|
35
|
+except KeyError:
|
|
36
|
+ chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
|
37
|
+ s_key = ''.join([random.choice(chars) for n in range(50)])
|
|
38
|
+ secret_key_warning = "You need to create a config.py file including a variable config which is a dict with at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key)
|
|
39
|
+ raise KeyError(secret_key_warning)
|
|
40
|
+# SECURITY WARNING: don't run with debug turned on in production!
|
|
41
|
+#
|
|
42
|
+DEBUG = False
|
|
43
|
+
|
|
44
|
+ALLOWED_HOSTS = config.get('ALLOWED_HOSTS', [])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+# Application definition
|
|
48
|
+#
|
|
49
|
+INSTALLED_APPS = [
|
|
50
|
+ 'pygal.apps.PygalConfig',
|
|
51
|
+ 'themes.apps.ThemesConfig',
|
|
52
|
+ 'users.apps.UsersConfig',
|
|
53
|
+ #
|
|
54
|
+ 'django.contrib.admin',
|
|
55
|
+ 'django.contrib.auth',
|
|
56
|
+ 'django.contrib.contenttypes',
|
|
57
|
+ 'django.contrib.sessions',
|
|
58
|
+ 'django.contrib.messages',
|
|
59
|
+ 'django.contrib.staticfiles',
|
|
60
|
+]
|
|
61
|
+
|
|
62
|
+MIDDLEWARE = [
|
|
63
|
+ 'django.middleware.security.SecurityMiddleware',
|
|
64
|
+ 'django.contrib.sessions.middleware.SessionMiddleware',
|
|
65
|
+ 'django.middleware.locale.LocaleMiddleware',
|
|
66
|
+ 'django.middleware.common.CommonMiddleware',
|
|
67
|
+ 'django.middleware.csrf.CsrfViewMiddleware',
|
|
68
|
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
69
|
+ 'django.contrib.messages.middleware.MessageMiddleware',
|
|
70
|
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
71
|
+ 'users.middleware.SettingsMiddleware',
|
|
72
|
+]
|
|
73
|
+
|
|
74
|
+ROOT_URLCONF = 'main.urls'
|
|
75
|
+
|
|
76
|
+TEMPLATES = [
|
|
77
|
+ {
|
|
78
|
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
79
|
+ 'DIRS': [],
|
|
80
|
+ 'APP_DIRS': True,
|
|
81
|
+ 'OPTIONS': {
|
|
82
|
+ 'context_processors': [
|
|
83
|
+ 'django.template.context_processors.debug',
|
|
84
|
+ 'django.template.context_processors.request',
|
|
85
|
+ 'django.contrib.auth.context_processors.auth',
|
|
86
|
+ 'django.contrib.messages.context_processors.messages',
|
|
87
|
+ ],
|
|
88
|
+ },
|
|
89
|
+ },
|
|
90
|
+]
|
|
91
|
+
|
|
92
|
+WSGI_APPLICATION = 'main.wsgi.application'
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+# Database
|
|
96
|
+# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
|
97
|
+#
|
|
98
|
+DATABASES = {
|
|
99
|
+ 'default': {
|
|
100
|
+ 'ENGINE': 'django.db.backends.sqlite3',
|
|
101
|
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
102
|
+ }
|
|
103
|
+}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+# Password validation
|
|
107
|
+# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
|
108
|
+#
|
|
109
|
+AUTH_PASSWORD_VALIDATORS = [
|
|
110
|
+ {
|
|
111
|
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
112
|
+ },
|
|
113
|
+ {
|
|
114
|
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
115
|
+ },
|
|
116
|
+ {
|
|
117
|
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
118
|
+ },
|
|
119
|
+ {
|
|
120
|
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
121
|
+ },
|
|
122
|
+]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+# Search Engine
|
|
126
|
+#
|
|
127
|
+WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+# Internationalization
|
|
131
|
+# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
|
132
|
+#
|
|
133
|
+LANGUAGE_CODE = 'en-us'
|
|
134
|
+LANGUAGES = [
|
|
135
|
+ ('en', 'English'),
|
|
136
|
+ ('de', 'Deutsch'),
|
|
137
|
+]
|
|
138
|
+
|
|
139
|
+TIME_ZONE = 'UTC'
|
|
140
|
+
|
|
141
|
+USE_I18N = True
|
|
142
|
+LOCALE_PATHS = [
|
|
143
|
+ os.path.join(BASE_DIR, 'themes', 'locale'),
|
|
144
|
+ os.path.join(BASE_DIR, 'users', 'locale'),
|
|
145
|
+ os.path.join(BASE_DIR, 'pygal', 'locale'),
|
|
146
|
+]
|
|
147
|
+
|
|
148
|
+USE_L10N = True
|
|
149
|
+
|
|
150
|
+USE_TZ = True
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+# Static files (CSS, JavaScript, Images)
|
|
154
|
+# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
155
|
+#
|
|
156
|
+STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
|
|
157
|
+STATIC_URL = '/static/'
|
|
158
|
+
|
|
159
|
+MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
|
|
160
|
+MEDIA_URL = '/media/'
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+# Session parameters
|
|
164
|
+#
|
|
165
|
+
|
|
166
|
+SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
|
|
167
|
+SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
|
|
168
|
+PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+# Logging Configuration
|
|
172
|
+#
|
|
173
|
+default_handler = ['console_long'] if DEBUG else ['console']
|
|
174
|
+#
|
|
175
|
+LOGGING = {
|
|
176
|
+ 'version': 1,
|
|
177
|
+ 'disable_existing_loggers': False,
|
|
178
|
+ 'formatters': {
|
|
179
|
+ 'short': {
|
|
180
|
+ 'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
|
|
181
|
+ 'datefmt': '[%d/%b/%Y %H:%M:%S]',
|
|
182
|
+ },
|
|
183
|
+ 'long': {
|
|
184
|
+ 'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
185
|
+File "%(pathname)s", line %(lineno)d, in %(funcName)s
|
|
186
|
+%(asctime)s: %(name)s - %(message)s
|
|
187
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
|
|
188
|
+ },
|
|
189
|
+ },
|
|
190
|
+ 'handlers': {
|
|
191
|
+ 'console': {
|
|
192
|
+ 'level': 'DEBUG',
|
|
193
|
+ 'class': 'logging.StreamHandler',
|
|
194
|
+ 'formatter': 'short',
|
|
195
|
+ },
|
|
196
|
+ 'console_long': {
|
|
197
|
+ 'level': 'DEBUG',
|
|
198
|
+ 'class': 'logging.StreamHandler',
|
|
199
|
+ 'formatter': 'long',
|
|
200
|
+ },
|
|
201
|
+ },
|
|
202
|
+ 'loggers': {
|
|
203
|
+ 'AUTH': {
|
|
204
|
+ 'handlers': default_handler,
|
|
205
|
+ 'level': 'INFO',
|
|
206
|
+ 'propagate': False,
|
|
207
|
+ },
|
|
208
|
+ 'APP': {
|
|
209
|
+ 'handlers': default_handler,
|
|
210
|
+ 'level': 'INFO',
|
|
211
|
+ 'propagate': False,
|
|
212
|
+ },
|
|
213
|
+ 'CACHING': {
|
|
214
|
+ 'handlers': default_handler,
|
|
215
|
+ 'level': 'INFO',
|
|
216
|
+ 'propagate': False,
|
|
217
|
+ },
|
|
218
|
+ 'WHOOSH': {
|
|
219
|
+ 'handlers': default_handler,
|
|
220
|
+ 'level': 'INFO',
|
|
221
|
+ 'propagate': False,
|
|
222
|
+ },
|
|
223
|
+ 'FSTOOLS': {
|
|
224
|
+ 'handlers': default_handler,
|
|
225
|
+ 'level': 'INFO',
|
|
226
|
+ 'propagate': False,
|
|
227
|
+ },
|
|
228
|
+ 'GEO': {
|
|
229
|
+ 'handlers': default_handler,
|
|
230
|
+ 'level': 'INFO',
|
|
231
|
+ 'propagate': False,
|
|
232
|
+ },
|
|
233
|
+ },
|
|
234
|
+}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+# Other Configuration issues
|
|
238
|
+#
|
|
239
|
+
|
|
240
|
+DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
|
|
241
|
+
|
|
242
|
+LOGIN_URL = 'users-login'
|
|
243
|
+
|
|
244
|
+XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
|
|
245
|
+TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+# App Configuration
|
|
249
|
+#
|
|
250
|
+DEFAULT_THEME = config.get('DEFAULT_THEME', 'clear-red')
|
|
251
|
+ITEM_ROOT = config.get('ITEM_ROOT', os.path.join(BASE_DIR, 'data', 'example_data'))
|
|
252
|
+THUMBNAIL_SIZES = config.get('THUMBNAIL_SIZES', [137, 175, 250])
|
|
253
|
+WEBNAIL_SIZES = config.get('WEBNAIL_SIZES', [450, 1100, 1750])
|