Преглед на файлове

django_lib update

master
Dirk Alders преди 3 седмици
родител
ревизия
d9228b68f2
променени са 6 файла, в които са добавени 98 реда и са изтрити 93 реда
  1. 23
    11
      config_example/config.py
  2. 71
    78
      main/settings.py
  3. 1
    1
      mycreole
  4. 1
    1
      patt
  5. 1
    1
      themes
  6. 1
    1
      users

+ 23
- 11
config_example/config.py Целия файл

@@ -1,20 +1,32 @@
1
+#######################################################################
2
+# Configuration of your django application
3
+#######################################################################
1 4
 #
2
-# General settings
5
+# Users library
3 6
 #
7
+# This enables or disables the self registration
8
+USERS_SELF_REGISTRATION = False
4 9
 
5
-# APP_NAME is used for logging
6
-APP_NAME = 'patt'
10
+#
11
+# Themes library
12
+#
13
+# This defines the default theme, if no theme is set in the django parameters
14
+DEFAULT_THEME = 'clear-green'
7 15
 
16
+#
17
+# Django
18
+#
19
+# This defines the mode of the running server
8 20
 # SECURITY WARNING: don't run with debug turned on in production!
9
-# DEBUG = False
21
+DEBUG = False
10 22
 
11
-# SECURITY WARNING: don't run with a dummy secret in production!
12
-# SECRET_KEY = None
23
+# This a the secret key for your application.
24
+# SECURITY WARNING: don't run with a dummy secret in production! And don't let others read this key!
25
+SECRET_KEY = None
13 26
 
27
+# This defines the listener hostnames for your django server
14 28
 # SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing!
15
-# ALLOWED_HOSTS = ['127.0.0.1', ]
29
+# ALLOWED_HOSTS = ['<YOUR_SERVER_HOSTNAME>', ]
16 30
 
17
-#
18
-# Style settings
19
-#
20
-# DEFAULT_THEME = 'clear-green'
31
+# This might be needed for usage in a docker environment
32
+# CSRF_TRUSTED_ORIGINS = ['<YOUR_SERVER_URL>', ]

+ 71
- 78
main/settings.py Целия файл

@@ -1,78 +1,39 @@
1 1
 """
2
-Django settings for this project.
2
+Django settings for patt project.
3 3
 
4
-Generated by 'django-admin startproject' using Django 3.0.3.
4
+Generated by 'django-admin startproject' using Django 5.1.1.
5 5
 
6 6
 For more information on this file, see
7
-https://docs.djangoproject.com/en/3.0/topics/settings/
7
+https://docs.djangoproject.com/en/5.1/topics/settings/
8 8
 
9 9
 For the full list of settings and their values, see
10 10
 https://docs.djangoproject.com/en/3.0/ref/settings/
11 11
 """
12 12
 
13
+from pathlib import Path
14
+
13 15
 import config
14 16
 from logging.handlers import SocketHandler as _SocketHandler
15 17
 import os
18
+import random
16 19
 import stat
17 20
 import sys
18
-import random
19
-
20
-try:
21
-    from config import APP_NAME as ROOT_LOGGER_NAME
22
-except ImportError:
23
-    ROOT_LOGGER_NAME = 'root'
24 21
 
22
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
23
+BASE_DIR = Path(__file__).resolve().parent.parent
25 24
 
26
-# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
27
-#
28
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
29
-
30
-# Check permission of config.py
31
-#
32
-if sys.platform == 'linux' or sys.platform == 'linux2':
33
-    st = os.stat(os.path.join(BASE_DIR, 'config.py'))
34
-    if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
35
-        raise PermissionError("conig.py is readable by group or others.")
36
-
37
-# Default values, if not defined in config.py
38
-#
39
-USER_CONFIG_DEFAULTS = {
40
-    'DEBUG': False,
41
-    'SECRET_KEY': None,
42
-    'DEFAULT_THEME': 'clear-green',
43
-    'ALLOWED_HOSTS': ['127.0.0.1', ],
44
-    'CSRF_TRUSTED_ORIGINS': [],
45
-}
46
-
47
-# Set configuration parameters
48
-#
49
-thismodule = sys.modules[__name__]
50
-for property_name in USER_CONFIG_DEFAULTS:
51
-    try:
52
-        value = getattr(config, property_name)
53
-    except AttributeError:
54
-        value = USER_CONFIG_DEFAULTS[property_name]
55
-    setattr(thismodule, property_name, value)
56 25
 
57 26
 # Quick-start development settings - unsuitable for production
58 27
 # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
59 28
 
60
-# SECURITY WARNING: keep the secret key used in production secret!
61
-#
62
-if SECRET_KEY is None:
63
-    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
64
-    s_key = ''.join([random.choice(chars) for n in range(50)])
65
-    secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
66
-    raise KeyError(secret_key_warning)
67
-
68 29
 
69 30
 # Application definition
70
-#
31
+
71 32
 INSTALLED_APPS = [
72 33
     'patt.apps.PattConfig',
73 34
     'themes.apps.ThemesConfig',
74
-    'users.apps.UsersConfig',
75 35
     'mycreole.apps.MycreoleConfig',
36
+    'users.apps.UsersConfig',
76 37
     #
77 38
     'django.contrib.admin',
78 39
     'django.contrib.auth',
@@ -118,19 +79,19 @@ WSGI_APPLICATION = 'main.wsgi.application'
118 79
 
119 80
 
120 81
 # Database
121
-# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
122
-#
82
+# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
83
+
123 84
 DATABASES = {
124 85
     'default': {
125 86
         'ENGINE': 'django.db.backends.sqlite3',
126
-        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
87
+        'NAME': BASE_DIR / 'db.sqlite3',
127 88
     }
128 89
 }
129 90
 
130 91
 
131 92
 # Password validation
132
-# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
133
-#
93
+# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
94
+
134 95
 AUTH_PASSWORD_VALIDATORS = [
135 96
     {
136 97
         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
@@ -147,14 +108,9 @@ AUTH_PASSWORD_VALIDATORS = [
147 108
 ]
148 109
 
149 110
 
150
-# Search Engine
151
-#
152
-WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
153
-
154
-
155 111
 # Internationalization
156
-# https://docs.djangoproject.com/en/3.0/topics/i18n/
157
-#
112
+# https://docs.djangoproject.com/en/5.1/topics/i18n/
113
+
158 114
 LANGUAGE_CODE = 'en-us'
159 115
 LANGUAGES = [
160 116
     ('en', 'English'),
@@ -176,10 +132,9 @@ USE_TZ = True
176 132
 
177 133
 
178 134
 # Static files (CSS, JavaScript, Images)
179
-# https://docs.djangoproject.com/en/3.0/howto/static-files/
180
-#
135
+# https://docs.djangoproject.com/en/5.1/howto/static-files/
181 136
 STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
182
-STATIC_URL = '/static/'
137
+STATIC_URL = 'static/'
183 138
 
184 139
 MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
185 140
 MEDIA_URL = '/media/'
@@ -189,18 +144,67 @@ MYCREOLE_ATTACHMENT_ACCESS = {
189 144
     'read': 'patt.access.read_attachment',
190 145
     'modify': 'patt.access.modify_attachment',
191 146
 }
147
+MYCREOLE_BAR = {
148
+    'navibar': 'patt.context.navigationbar',
149
+    'menubar': 'patt.context.menubar',
150
+}
192 151
 MYCREOLE_EXT_FILTERS = [
193 152
     'patt.creole.task_link_filter',
194 153
     'patt.creole.tasklist_link_filter',
195 154
 ]
196 155
 
197
-# Session parameters
156
+WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
157
+
158
+LOGIN_URL = 'users-login'
159
+
160
+# Default primary key field type
161
+# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
162
+
163
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
164
+
165
+
166
+# Check permission of config.py
167
+#
168
+if sys.platform == 'linux' or sys.platform == 'linux2':
169
+    st = os.stat(os.path.join(BASE_DIR, 'config.py'))
170
+    if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
171
+        raise PermissionError("conig.py is readable by group or others.")
172
+
173
+# Default values, if not defined in config.py
174
+#
175
+USER_CONFIG_DEFAULTS = {
176
+    'DEBUG': False,
177
+    'SECRET_KEY': None,
178
+    'DEFAULT_THEME': 'clear-green',
179
+    'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
180
+    'CSRF_TRUSTED_ORIGINS': [],
181
+}
182
+
183
+# Set configuration parameters
184
+#
185
+thismodule = sys.modules[__name__]
186
+for property_name in USER_CONFIG_DEFAULTS:
187
+    try:
188
+        value = getattr(config, property_name)
189
+    except AttributeError:
190
+        value = USER_CONFIG_DEFAULTS[property_name]
191
+    setattr(thismodule, property_name, value)
192
+
193
+# SECURITY WARNING: keep the secret key used in production secret!
198 194
 #
199
-PERSISTENT_SESSION_VARIABLES = []
195
+if SECRET_KEY is None:
196
+    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
197
+    s_key = ''.join([random.choice(chars) for n in range(50)])
198
+    secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
199
+    raise KeyError(secret_key_warning)
200 200
 
201 201
 
202 202
 # Logging Configuration
203 203
 #
204
+ROOT_LOGGER_NAME = os.path.basename(os.path.dirname(__file__))
205
+default_handler = ['socket'] if DEBUG else ['console']
206
+
207
+
204 208
 class DjangoSocketHandler(_SocketHandler):
205 209
     def emit(self, record):
206 210
         if hasattr(record, 'request'):
@@ -208,8 +212,6 @@ class DjangoSocketHandler(_SocketHandler):
208 212
         return super().emit(record)
209 213
 
210 214
 
211
-default_handler = ['socket'] if DEBUG else ['console']
212
-#
213 215
 LOGGING = {
214 216
     'version': 1,
215 217
     'disable_existing_loggers': False,
@@ -233,7 +235,7 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
233 235
         },
234 236
         'socket': {
235 237
             'level': 'DEBUG',
236
-            'class': 'main.settings.DjangoSocketHandler',
238
+            'class': f'{ROOT_LOGGER_NAME}.settings.DjangoSocketHandler',
237 239
             'host': '127.0.0.1',
238 240
             'port': 19996,
239 241
         },
@@ -251,12 +253,3 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
251 253
         },
252 254
     },
253 255
 }
254
-
255
-
256
-# Other Configuration issues
257
-#
258
-LOGIN_URL = 'users-login'
259
-
260
-# Default Auto Filed
261
-#
262
-DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

+ 1
- 1
mycreole

@@ -1 +1 @@
1
-Subproject commit 057388e3b44b5fe42b133fe030c41aa6a254de58
1
+Subproject commit 997594e37149b55e598f7dedfefed3c2998a2c87

+ 1
- 1
patt

@@ -1 +1 @@
1
-Subproject commit be03b653ebce2dadb5bfb314e597966751fb9cf7
1
+Subproject commit 577956248e382ff47c5d0c668ee8ffbfe2f4cbd8

+ 1
- 1
themes

@@ -1 +1 @@
1
-Subproject commit 13a8d8ebc4c82d2000af4464b863cf3b38a7a1fe
1
+Subproject commit 261ef5048efb4bd204a4ddbe56a90f96cd767ba1

+ 1
- 1
users

@@ -1 +1 @@
1
-Subproject commit 0827a5311fdbbef689365c6db5762881e048ba9c
1
+Subproject commit c9532aaf37cc785583d7ffc89d1d2f738985171d

Loading…
Отказ
Запис