|
@@ -10,10 +10,10 @@ For the full list of settings and their values, see
|
10
|
10
|
https://docs.djangoproject.com/en/5.1/ref/settings/
|
11
|
11
|
"""
|
12
|
12
|
|
|
13
|
+from pathlib import Path
|
|
14
|
+
|
13
|
15
|
import config
|
14
|
|
-from config import APP_NAME as ROOT_LOGGER_NAME
|
15
|
16
|
import os
|
16
|
|
-from pathlib import Path
|
17
|
17
|
import random
|
18
|
18
|
import stat
|
19
|
19
|
import sys
|
|
@@ -21,40 +21,6 @@ import sys
|
21
|
21
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
22
|
22
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
23
|
23
|
|
24
|
|
-# Check permission of config.py
|
25
|
|
-#
|
26
|
|
-if sys.platform == 'linux' or sys.platform == 'linux2':
|
27
|
|
- st = os.stat(os.path.join(BASE_DIR, 'config.py'))
|
28
|
|
- if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
|
29
|
|
- raise PermissionError("conig.py is readable by group or others.")
|
30
|
|
-
|
31
|
|
-# Default values, if not defined in config.py
|
32
|
|
-#
|
33
|
|
-USER_CONFIG_DEFAULTS = {
|
34
|
|
- 'DEBUG': False,
|
35
|
|
- 'SECRET_KEY': None,
|
36
|
|
- 'DEFAULT_THEME': 'clear-blue',
|
37
|
|
- 'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
|
38
|
|
- 'CSRF_TRUSTED_ORIGINS': [],
|
39
|
|
-}
|
40
|
|
-
|
41
|
|
-# Set configuration parameters
|
42
|
|
-#
|
43
|
|
-thismodule = sys.modules[__name__]
|
44
|
|
-for property_name in USER_CONFIG_DEFAULTS:
|
45
|
|
- try:
|
46
|
|
- value = getattr(config, property_name)
|
47
|
|
- except AttributeError:
|
48
|
|
- value = USER_CONFIG_DEFAULTS[property_name]
|
49
|
|
- setattr(thismodule, property_name, value)
|
50
|
|
-
|
51
|
|
-# SECURITY WARNING: keep the secret key used in production secret!
|
52
|
|
-#
|
53
|
|
-if SECRET_KEY is None:
|
54
|
|
- chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
55
|
|
- s_key = ''.join([random.choice(chars) for n in range(50)])
|
56
|
|
- secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--). " % repr(s_key)
|
57
|
|
- raise KeyError(secret_key_warning)
|
58
|
24
|
|
59
|
25
|
# Quick-start development settings - unsuitable for production
|
60
|
26
|
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
|
@@ -148,8 +114,72 @@ USE_I18N = True
|
148
|
114
|
|
149
|
115
|
USE_TZ = True
|
150
|
116
|
|
|
117
|
+
|
|
118
|
+# Static files (CSS, JavaScript, Images)
|
|
119
|
+# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
|
120
|
+STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
|
|
121
|
+STATIC_URL = 'static/'
|
|
122
|
+
|
|
123
|
+MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
|
|
124
|
+MEDIA_URL = '/media/'
|
|
125
|
+
|
|
126
|
+MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'pages')
|
|
127
|
+MYCREOLE_ATTACHMENT_ACCESS = {
|
|
128
|
+ 'read': 'pages.access.read_attachment',
|
|
129
|
+ 'modify': 'pages.access.modify_attachment',
|
|
130
|
+}
|
|
131
|
+MYCREOLE_BAR = {
|
|
132
|
+ 'navibar': 'pages.context.navigationbar',
|
|
133
|
+ 'menubar': 'pages.context.menubar',
|
|
134
|
+}
|
|
135
|
+
|
|
136
|
+PAGES_ROOT = os.path.join(BASE_DIR, 'data', 'pages')
|
|
137
|
+
|
|
138
|
+# Default primary key field type
|
|
139
|
+# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
|
140
|
+
|
|
141
|
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+# Check permission of config.py
|
|
145
|
+#
|
|
146
|
+if sys.platform == 'linux' or sys.platform == 'linux2':
|
|
147
|
+ st = os.stat(os.path.join(BASE_DIR, 'config.py'))
|
|
148
|
+ if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
|
|
149
|
+ raise PermissionError("conig.py is readable by group or others.")
|
|
150
|
+
|
|
151
|
+# Default values, if not defined in config.py
|
|
152
|
+#
|
|
153
|
+USER_CONFIG_DEFAULTS = {
|
|
154
|
+ 'DEBUG': False,
|
|
155
|
+ 'SECRET_KEY': None,
|
|
156
|
+ 'DEFAULT_THEME': 'clear-blue',
|
|
157
|
+ 'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
|
|
158
|
+ 'CSRF_TRUSTED_ORIGINS': [],
|
|
159
|
+}
|
|
160
|
+
|
|
161
|
+# Set configuration parameters
|
|
162
|
+#
|
|
163
|
+thismodule = sys.modules[__name__]
|
|
164
|
+for property_name in USER_CONFIG_DEFAULTS:
|
|
165
|
+ try:
|
|
166
|
+ value = getattr(config, property_name)
|
|
167
|
+ except AttributeError:
|
|
168
|
+ value = USER_CONFIG_DEFAULTS[property_name]
|
|
169
|
+ setattr(thismodule, property_name, value)
|
|
170
|
+
|
|
171
|
+# SECURITY WARNING: keep the secret key used in production secret!
|
|
172
|
+#
|
|
173
|
+if SECRET_KEY is None:
|
|
174
|
+ chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
|
|
175
|
+ s_key = ''.join([random.choice(chars) for n in range(50)])
|
|
176
|
+ secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--). " % repr(s_key)
|
|
177
|
+ raise KeyError(secret_key_warning)
|
|
178
|
+
|
|
179
|
+
|
151
|
180
|
# Logging Configuration
|
152
|
181
|
#
|
|
182
|
+ROOT_LOGGER_NAME = 'apps'
|
153
|
183
|
LOGGING = {
|
154
|
184
|
'version': 1,
|
155
|
185
|
'disable_existing_loggers': False,
|
|
@@ -186,27 +216,3 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
|
186
|
216
|
},
|
187
|
217
|
}
|
188
|
218
|
|
189
|
|
-# Static files (CSS, JavaScript, Images)
|
190
|
|
-# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
191
|
|
-
|
192
|
|
-STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
|
193
|
|
-STATIC_URL = 'static/'
|
194
|
|
-
|
195
|
|
-MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
|
196
|
|
-MEDIA_URL = '/media/'
|
197
|
|
-
|
198
|
|
-PAGES_ROOT = os.path.join(BASE_DIR, 'data', 'pages')
|
199
|
|
-
|
200
|
|
-MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'pages')
|
201
|
|
-MYCREOLE_ATTACHMENT_ACCESS = {
|
202
|
|
- 'read': 'pages.access.read_attachment',
|
203
|
|
- 'modify': 'pages.access.modify_attachment',
|
204
|
|
-}
|
205
|
|
-MYCREOLE_BAR = {
|
206
|
|
- 'navibar': 'pages.context.navigationbar',
|
207
|
|
- 'menubar': 'pages.context.menubar',
|
208
|
|
-}
|
209
|
|
-# Default primary key field type
|
210
|
|
-# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
211
|
|
-
|
212
|
|
-DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|