Przeglądaj źródła

Adaption to new libraries

master
Dirk Alders 1 miesiąc temu
rodzic
commit
d6c4634045
13 zmienionych plików z 169 dodań i 129 usunięć
  1. 17
    0
      .vscode/launch.json
  2. 15
    0
      .vscode/settings.json
  3. 36
    29
      config_example/config.py
  4. 1
    1
      fstools
  5. 88
    89
      main/settings.py
  6. 0
    0
      manage.py
  7. 1
    1
      media
  8. 1
    1
      mycreole
  9. 1
    1
      pygal
  10. 6
    4
      requirements.txt
  11. 1
    1
      stringtools
  12. 1
    1
      themes
  13. 1
    1
      users

+ 17
- 0
.vscode/launch.json Wyświetl plik

1
+{
2
+    // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
3
+    // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
4
+    // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
5
+    "version": "0.2.0",
6
+    "configurations": [
7
+        {
8
+            "name": "Python: Main File execution",
9
+            "type": "python",
10
+            "request": "launch",
11
+            "program": "${workspaceFolder}/manage.py",
12
+            "args": ["runserver"],
13
+            "console": "integratedTerminal",
14
+            "justMyCode": true
15
+        }
16
+    ]
17
+}

+ 15
- 0
.vscode/settings.json Wyświetl plik

1
+{
2
+  "python.defaultInterpreterPath": "./venv/bin/python",
3
+  "autopep8.args": ["--max-line-length=150"],
4
+  "python.formatting.provider": "none",
5
+  "[python]": {
6
+    "editor.defaultFormatter": "ms-python.python",
7
+    "editor.formatOnSave": true
8
+  },
9
+  "editor.formatOnSave": true,
10
+  "editor.fontSize": 14,
11
+  "emmet.includeLanguages": { "django-html": "html" },
12
+  "python.testing.pytestArgs": ["-v", "--cov", "--cov-report=xml", "__test__"],
13
+  "python.testing.unittestEnabled": false,
14
+  "python.testing.pytestEnabled": true
15
+}

+ 36
- 29
config_example/config.py Wyświetl plik

1
 import os
1
 import os
2
 
2
 
3
 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
3
 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
4
-
4
+#######################################################################
5
+# Configuration of your django application
6
+#######################################################################
5
 #
7
 #
6
-# General settings
8
+# PyGal Setting
7
 #
9
 #
10
+# The root for searching for items
11
+ITEM_ROOT = os.path.join(BASE_DIR, 'data', 'example_data')
12
+# Set this to True to ensure, that unauthenticated users have no permission (With False they get permiisions to the
13
+# structure. You can set public in the item (folde) to make the items visible)
14
+#SUSPEND_PUBLIC = False
8
 
15
 
9
-# APP_NAME is used for logging
10
-APP_NAME = 'pygal'
11
-
12
-# SECURITY WARNING: don't run with debug turned on in production!
13
-# DEBUG = False
16
+# THUMBNAIL_SIZES = [137, 175, 250]
17
+# WEBNAIL_SIZES = [450, 1100, 1750]
18
+# SORT_BY_DATE = True       # Sorting by name if False
19
+# SHOW_IMAGE = True
20
+# SHOW_VIDEO = True
21
+# SHOW_AUDIO = False
22
+# SHOW_OTHER = False
14
 
23
 
15
-# SECURITY WARNING: don't run with a dummy secret in production!
16
-# SECRET_KEY = 'define a secret key'
24
+# Access Right settings
17
 
25
 
18
-# SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing!
19
-# ALLOWED_HOSTS = ['127.0.0.1', ]
20
 
26
 
21
 #
27
 #
22
-# ITEM_ROOT = os.path.join(BASE_DIR, 'data', 'example_data')
28
+# Users library
29
+#
30
+# This enables or disables the self registration
31
+USERS_SELF_REGISTRATION = False
23
 
32
 
24
 #
33
 #
25
-# Access Right settings
34
+# Themes library
26
 #
35
 #
27
-
28
-# Set this to True to ensure, that unauthenticated users have no permission
29
-# SUSPEND_PUBLIC = True
36
+# This defines the default theme, if no theme is set in the django parameters
37
+DEFAULT_THEME = 'clear-red'
30
 
38
 
31
 #
39
 #
32
-# Style settings
40
+# Django
33
 #
41
 #
42
+# This defines the mode of the running server
43
+# SECURITY WARNING: don't run with debug turned on in production!
44
+DEBUG = False
34
 
45
 
35
-# DEFAULT_THEME = 'clear-red'
36
-# THUMBNAIL_SIZES = [137, 175, 250]
37
-# WEBNAIL_SIZES = [450, 1100, 1750]
46
+# This a the secret key for your application.
47
+# SECURITY WARNING: don't run with a dummy secret in production! And don't let others read this key!
48
+SECRET_KEY = None
38
 
49
 
39
-#
40
-# Content settings
41
-#
50
+# This defines the listener hostnames for your django server
51
+# SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing!
52
+# ALLOWED_HOSTS = ['<YOUR_SERVER_HOSTNAME>', ]
42
 
53
 
43
-# Sorting by name if False
44
-# SORT_BY_DATE = True
45
-# SHOW_IMAGE = True
46
-# SHOW_VIDEO = True
47
-# SHOW_AUDIO = False
48
-# SHOW_OTHER = False
54
+# This might be needed for usage in a docker environment
55
+# CSRF_TRUSTED_ORIGINS = ['<YOUR_SERVER_URL>', ]

+ 1
- 1
fstools

1
-Subproject commit f5da43b01631147dace87242a94227acfb3e9bc5
1
+Subproject commit c10e8792abb05671dab6de51cdadda3bf8ead50f

+ 88
- 89
main/settings.py Wyświetl plik

1
 """
1
 """
2
-Django settings for this project.
2
+Django settings for pygal 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
 For more information on this file, see
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
 For the full list of settings and their values, see
9
 For the full list of settings and their values, see
10
-https://docs.djangoproject.com/en/3.0/ref/settings/
10
+https://docs.djangoproject.com/en/5.1/ref/settings/
11
 """
11
 """
12
 
12
 
13
+from pathlib import Path
14
+
13
 import config
15
 import config
14
 from logging.handlers import SocketHandler as _SocketHandler
16
 from logging.handlers import SocketHandler as _SocketHandler
15
 import os
17
 import os
18
+import random
16
 import stat
19
 import stat
17
 import sys
20
 import sys
18
-import random
19
 
21
 
20
-try:
21
-    from config import APP_NAME as ROOT_LOGGER_NAME
22
-except ImportError:
23
-    ROOT_LOGGER_NAME = 'root'
22
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
23
+BASE_DIR = Path(__file__).resolve().parent.parent
24
 
24
 
25
 
25
 
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
-    'ALLOWED_HOSTS': ['127.0.0.1', ],
43
-    'CSRF_TRUSTED_ORIGINS': [],
44
-    'DEFAULT_THEME': 'clear-red',
45
-    'ITEM_ROOT': os.path.join(BASE_DIR, 'data', 'example_data'),
46
-    'THUMBNAIL_SIZES': [137, 175, 250],
47
-    'WEBNAIL_SIZES': [450, 1100, 1750],
48
-    'SUSPEND_PUBLIC': True,
49
-    'SORT_BY_DATE': True,
50
-    'SHOW_IMAGE': True,
51
-    'SHOW_VIDEO': True,
52
-    'SHOW_AUDIO': False,
53
-    'SHOW_OTHER': False,
54
-}
55
-
56
-# Set configuration parameters
57
-#
58
-thismodule = sys.modules[__name__]
59
-for property_name in USER_CONFIG_DEFAULTS:
60
-    try:
61
-        value = getattr(config, property_name)
62
-    except AttributeError:
63
-        value = USER_CONFIG_DEFAULTS[property_name]
64
-    setattr(thismodule, property_name, value)
65
-
66
 # Quick-start development settings - unsuitable for production
26
 # Quick-start development settings - unsuitable for production
67
-# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
68
-
69
-# SECURITY WARNING: keep the secret key used in production secret!
70
-#
71
-if SECRET_KEY is None:
72
-    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
73
-    s_key = ''.join([random.choice(chars) for n in range(50)])
74
-    secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
75
-    raise KeyError(secret_key_warning)
27
+# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
76
 
28
 
77
 
29
 
78
 # Application definition
30
 # Application definition
79
-#
31
+
80
 INSTALLED_APPS = [
32
 INSTALLED_APPS = [
81
     'pygal.apps.PygalConfig',
33
     'pygal.apps.PygalConfig',
82
     'themes.apps.ThemesConfig',
34
     'themes.apps.ThemesConfig',
124
 
76
 
125
 
77
 
126
 # Database
78
 # Database
127
-# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
128
-#
79
+# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
80
+
129
 DATABASES = {
81
 DATABASES = {
130
     'default': {
82
     'default': {
131
         'ENGINE': 'django.db.backends.sqlite3',
83
         'ENGINE': 'django.db.backends.sqlite3',
132
-        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
84
+        'NAME': BASE_DIR / 'db.sqlite3',
133
     }
85
     }
134
 }
86
 }
135
 
87
 
136
 
88
 
137
 # Password validation
89
 # Password validation
138
-# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
139
-#
90
+# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
91
+
140
 AUTH_PASSWORD_VALIDATORS = [
92
 AUTH_PASSWORD_VALIDATORS = [
141
     {
93
     {
142
         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94
         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
153
 ]
105
 ]
154
 
106
 
155
 
107
 
156
-# Search Engine
157
-#
158
-WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
159
-
160
-
161
 # Internationalization
108
 # Internationalization
162
-# https://docs.djangoproject.com/en/3.0/topics/i18n/
163
-#
109
+# https://docs.djangoproject.com/en/5.1/topics/i18n/
110
+
164
 LANGUAGE_CODE = 'en-us'
111
 LANGUAGE_CODE = 'en-us'
165
 LANGUAGES = [
112
 LANGUAGES = [
166
     ('en', 'English'),
113
     ('en', 'English'),
182
 
129
 
183
 
130
 
184
 # Static files (CSS, JavaScript, Images)
131
 # Static files (CSS, JavaScript, Images)
185
-# https://docs.djangoproject.com/en/3.0/howto/static-files/
186
-#
132
+# https://docs.djangoproject.com/en/5.1/howto/static-files/
187
 STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
133
 STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
188
-STATIC_URL = '/static/'
134
+STATIC_URL = 'static/'
189
 
135
 
190
 MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
136
 MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
191
 MEDIA_URL = '/media/'
137
 MEDIA_URL = '/media/'
192
 
138
 
139
+WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh')
193
 
140
 
194
-# Session parameters
141
+# Default primary key field type
142
+# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
143
+
144
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
145
+
146
+
147
+
148
+# Other Configuration issues
195
 #
149
 #
150
+DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
196
 
151
 
152
+LOGIN_URL = 'users-login'
153
+
154
+XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
155
+TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')
156
+
157
+
158
+# Session parameters
159
+#
197
 SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
160
 SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
198
 SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
161
 SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
199
 PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
162
 PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
200
 
163
 
201
 
164
 
165
+# Check permission of config.py
166
+#
167
+if sys.platform == 'linux' or sys.platform == 'linux2':
168
+    st = os.stat(os.path.join(BASE_DIR, 'config.py'))
169
+    if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
170
+        raise PermissionError("conig.py is readable by group or others.")
171
+
172
+# Default values, if not defined in config.py
173
+#
174
+USER_CONFIG_DEFAULTS = {
175
+    'ITEM_ROOT': os.path.join(BASE_DIR, 'data', 'example_data'),
176
+    'SUSPEND_PUBLIC': True,
177
+    'DEBUG': False,
178
+    'SECRET_KEY': None,
179
+    'DEFAULT_THEME': 'clear-red',
180
+    'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
181
+    'CSRF_TRUSTED_ORIGINS': [],
182
+    'THUMBNAIL_SIZES': [137, 175, 250],
183
+    'WEBNAIL_SIZES': [450, 1100, 1750],
184
+    'SORT_BY_DATE': True,
185
+    'SHOW_IMAGE': True,
186
+    'SHOW_VIDEO': True,
187
+    'SHOW_AUDIO': False,
188
+    'SHOW_OTHER': False,
189
+}
190
+
191
+# Set configuration parameters
192
+#
193
+thismodule = sys.modules[__name__]
194
+for property_name in USER_CONFIG_DEFAULTS:
195
+    try:
196
+        value = getattr(config, property_name)
197
+    except AttributeError:
198
+        value = USER_CONFIG_DEFAULTS[property_name]
199
+    setattr(thismodule, property_name, value)
200
+
201
+# SECURITY WARNING: keep the secret key used in production secret!
202
+#
203
+if SECRET_KEY is None:
204
+    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
205
+    s_key = ''.join([random.choice(chars) for n in range(50)])
206
+    secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
207
+    raise KeyError(secret_key_warning)
208
+
209
+
202
 # Logging Configuration
210
 # Logging Configuration
203
 #
211
 #
212
+ROOT_LOGGER_NAME = os.path.basename(os.path.dirname(__file__))
213
+default_handler = ['socket', 'console'] if DEBUG else ['console']
214
+
215
+
204
 class DjangoSocketHandler(_SocketHandler):
216
 class DjangoSocketHandler(_SocketHandler):
205
     def emit(self, record):
217
     def emit(self, record):
206
         if hasattr(record, 'request'):
218
         if hasattr(record, 'request'):
208
         return super().emit(record)
220
         return super().emit(record)
209
 
221
 
210
 
222
 
211
-default_handler = ['socket'] if DEBUG else ['console']
212
-#
213
 LOGGING = {
223
 LOGGING = {
214
     'version': 1,
224
     'version': 1,
215
     'disable_existing_loggers': False,
225
     'disable_existing_loggers': False,
233
         },
243
         },
234
         'socket': {
244
         'socket': {
235
             'level': 'DEBUG',
245
             'level': 'DEBUG',
236
-            'class': 'main.settings.DjangoSocketHandler',
246
+            'class': f'{ROOT_LOGGER_NAME}.settings.DjangoSocketHandler',
237
             'host': '127.0.0.1',
247
             'host': '127.0.0.1',
238
             'port': 19996,
248
             'port': 19996,
239
         },
249
         },
251
         },
261
         },
252
     },
262
     },
253
 }
263
 }
254
-
255
-
256
-# Other Configuration issues
257
-#
258
-
259
-DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
260
-
261
-LOGIN_URL = 'users-login'
262
-
263
-XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
264
-TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')

+ 0
- 0
manage.py Wyświetl plik


+ 1
- 1
media

1
-Subproject commit abcf63d02e866c3832d014c54f2a95acdfb7d304
1
+Subproject commit 402e8375511470c61021956edad72e1080f51c8e

+ 1
- 1
mycreole

1
-Subproject commit 5f30383c83b0ea94341b999c489a34f2e7d57f80
1
+Subproject commit 997594e37149b55e598f7dedfefed3c2998a2c87

+ 1
- 1
pygal

1
-Subproject commit 114a82e1768d3fbf8a83afb61b2f19c271b8868b
1
+Subproject commit 5f1420a0a9de7cd5b47cdf99bd9d86bee01a6ec7

+ 6
- 4
requirements.txt Wyświetl plik

1
-Django>=2.0.5
2
-Pillow>=5.4.1
3
-python-creole>=1.0.0
4
-Whoosh>=2.4.0
1
+Django
2
+Pillow
3
+disc-id
4
+pytz
5
+python-creole
6
+Whoosh

+ 1
- 1
stringtools

1
-Subproject commit c1d9cf49c34cc6c97cfb372eec4a30f0188181f9
1
+Subproject commit e1f76d96312e540544b2328d0937b0aa41126aa9

+ 1
- 1
themes

1
-Subproject commit d3b38d9e7a5d01708380dd9632b0ca7a544a5cef
1
+Subproject commit 261ef5048efb4bd204a4ddbe56a90f96cd767ba1

+ 1
- 1
users

1
-Subproject commit 0827a5311fdbbef689365c6db5762881e048ba9c
1
+Subproject commit c9532aaf37cc785583d7ffc89d1d2f738985171d

Ładowanie…
Anuluj
Zapisz