Adaption to new libraries

This commit is contained in:
Dirk Alders 2024-10-10 22:54:30 +02:00
parent a6c61ee3f3
commit d6c4634045
13 changed files with 176 additions and 136 deletions

17
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Main File execution",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": ["runserver"],
"console": "integratedTerminal",
"justMyCode": true
}
]
}

15
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"python.defaultInterpreterPath": "./venv/bin/python",
"autopep8.args": ["--max-line-length=150"],
"python.formatting.provider": "none",
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.formatOnSave": true
},
"editor.formatOnSave": true,
"editor.fontSize": 14,
"emmet.includeLanguages": { "django-html": "html" },
"python.testing.pytestArgs": ["-v", "--cov", "--cov-report=xml", "__test__"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}

View File

@ -1,48 +1,55 @@
import os import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
#######################################################################
# Configuration of your django application
#######################################################################
# #
# General settings # PyGal Setting
# #
# The root for searching for items
ITEM_ROOT = os.path.join(BASE_DIR, 'data', 'example_data')
# Set this to True to ensure, that unauthenticated users have no permission (With False they get permiisions to the
# structure. You can set public in the item (folde) to make the items visible)
#SUSPEND_PUBLIC = False
# APP_NAME is used for logging
APP_NAME = 'pygal'
# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = False
# SECURITY WARNING: don't run with a dummy secret in production!
# SECRET_KEY = 'define a secret key'
# SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing!
# ALLOWED_HOSTS = ['127.0.0.1', ]
#
# ITEM_ROOT = os.path.join(BASE_DIR, 'data', 'example_data')
#
# Access Right settings
#
# Set this to True to ensure, that unauthenticated users have no permission
# SUSPEND_PUBLIC = True
#
# Style settings
#
# DEFAULT_THEME = 'clear-red'
# THUMBNAIL_SIZES = [137, 175, 250] # THUMBNAIL_SIZES = [137, 175, 250]
# WEBNAIL_SIZES = [450, 1100, 1750] # WEBNAIL_SIZES = [450, 1100, 1750]
# SORT_BY_DATE = True # Sorting by name if False
#
# Content settings
#
# Sorting by name if False
# SORT_BY_DATE = True
# SHOW_IMAGE = True # SHOW_IMAGE = True
# SHOW_VIDEO = True # SHOW_VIDEO = True
# SHOW_AUDIO = False # SHOW_AUDIO = False
# SHOW_OTHER = False # SHOW_OTHER = False
# Access Right settings
#
# Users library
#
# This enables or disables the self registration
USERS_SELF_REGISTRATION = False
#
# Themes library
#
# This defines the default theme, if no theme is set in the django parameters
DEFAULT_THEME = 'clear-red'
#
# Django
#
# This defines the mode of the running server
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
# This a the secret key for your application.
# SECURITY WARNING: don't run with a dummy secret in production! And don't let others read this key!
SECRET_KEY = None
# This defines the listener hostnames for your django server
# SECURITY WARNING: don't run with '0.0.0.0' in in production, unless you know what you are doing!
# ALLOWED_HOSTS = ['<YOUR_SERVER_HOSTNAME>', ]
# This might be needed for usage in a docker environment
# CSRF_TRUSTED_ORIGINS = ['<YOUR_SERVER_URL>', ]

@ -1 +1 @@
Subproject commit f5da43b01631147dace87242a94227acfb3e9bc5 Subproject commit c10e8792abb05671dab6de51cdadda3bf8ead50f

View File

@ -1,82 +1,34 @@
""" """
Django settings for this project. Django settings for pygal project.
Generated by 'django-admin startproject' using Django 3.0.3. Generated by 'django-admin startproject' using Django 5.1.1.
For more information on this file, see For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/ https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/ https://docs.djangoproject.com/en/5.1/ref/settings/
""" """
from pathlib import Path
import config import config
from logging.handlers import SocketHandler as _SocketHandler from logging.handlers import SocketHandler as _SocketHandler
import os import os
import random
import stat import stat
import sys import sys
import random
try: # Build paths inside the project like this: BASE_DIR / 'subdir'.
from config import APP_NAME as ROOT_LOGGER_NAME BASE_DIR = Path(__file__).resolve().parent.parent
except ImportError:
ROOT_LOGGER_NAME = 'root'
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
#
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Check permission of config.py
#
if sys.platform == 'linux' or sys.platform == 'linux2':
st = os.stat(os.path.join(BASE_DIR, 'config.py'))
if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
raise PermissionError("conig.py is readable by group or others.")
# Default values, if not defined in config.py
#
USER_CONFIG_DEFAULTS = {
'DEBUG': False,
'SECRET_KEY': None,
'ALLOWED_HOSTS': ['127.0.0.1', ],
'CSRF_TRUSTED_ORIGINS': [],
'DEFAULT_THEME': 'clear-red',
'ITEM_ROOT': os.path.join(BASE_DIR, 'data', 'example_data'),
'THUMBNAIL_SIZES': [137, 175, 250],
'WEBNAIL_SIZES': [450, 1100, 1750],
'SUSPEND_PUBLIC': True,
'SORT_BY_DATE': True,
'SHOW_IMAGE': True,
'SHOW_VIDEO': True,
'SHOW_AUDIO': False,
'SHOW_OTHER': False,
}
# Set configuration parameters
#
thismodule = sys.modules[__name__]
for property_name in USER_CONFIG_DEFAULTS:
try:
value = getattr(config, property_name)
except AttributeError:
value = USER_CONFIG_DEFAULTS[property_name]
setattr(thismodule, property_name, value)
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
#
if SECRET_KEY is None:
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
s_key = ''.join([random.choice(chars) for n in range(50)])
secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
raise KeyError(secret_key_warning)
# Application definition # Application definition
#
INSTALLED_APPS = [ INSTALLED_APPS = [
'pygal.apps.PygalConfig', 'pygal.apps.PygalConfig',
'themes.apps.ThemesConfig', 'themes.apps.ThemesConfig',
@ -124,19 +76,19 @@ WSGI_APPLICATION = 'main.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
#
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': BASE_DIR / 'db.sqlite3',
} }
} }
# Password validation # Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
#
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
@ -153,14 +105,9 @@ AUTH_PASSWORD_VALIDATORS = [
] ]
# Search Engine
#
WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/ # https://docs.djangoproject.com/en/5.1/topics/i18n/
#
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
LANGUAGES = [ LANGUAGES = [
('en', 'English'), ('en', 'English'),
@ -182,25 +129,90 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/ # https://docs.djangoproject.com/en/5.1/howto/static-files/
#
STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static') STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
STATIC_URL = '/static/' STATIC_URL = 'static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh')
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Other Configuration issues
#
DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
LOGIN_URL = 'users-login'
XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')
# Session parameters # Session parameters
# #
SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size' SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
SESSION_KEY_WEBNAIL_SIZE = 'webnail_size' SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE] PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
# Check permission of config.py
#
if sys.platform == 'linux' or sys.platform == 'linux2':
st = os.stat(os.path.join(BASE_DIR, 'config.py'))
if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
raise PermissionError("conig.py is readable by group or others.")
# Default values, if not defined in config.py
#
USER_CONFIG_DEFAULTS = {
'ITEM_ROOT': os.path.join(BASE_DIR, 'data', 'example_data'),
'SUSPEND_PUBLIC': True,
'DEBUG': False,
'SECRET_KEY': None,
'DEFAULT_THEME': 'clear-red',
'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
'CSRF_TRUSTED_ORIGINS': [],
'THUMBNAIL_SIZES': [137, 175, 250],
'WEBNAIL_SIZES': [450, 1100, 1750],
'SORT_BY_DATE': True,
'SHOW_IMAGE': True,
'SHOW_VIDEO': True,
'SHOW_AUDIO': False,
'SHOW_OTHER': False,
}
# Set configuration parameters
#
thismodule = sys.modules[__name__]
for property_name in USER_CONFIG_DEFAULTS:
try:
value = getattr(config, property_name)
except AttributeError:
value = USER_CONFIG_DEFAULTS[property_name]
setattr(thismodule, property_name, value)
# SECURITY WARNING: keep the secret key used in production secret!
#
if SECRET_KEY is None:
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
s_key = ''.join([random.choice(chars) for n in range(50)])
secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
raise KeyError(secret_key_warning)
# Logging Configuration # Logging Configuration
# #
ROOT_LOGGER_NAME = os.path.basename(os.path.dirname(__file__))
default_handler = ['socket', 'console'] if DEBUG else ['console']
class DjangoSocketHandler(_SocketHandler): class DjangoSocketHandler(_SocketHandler):
def emit(self, record): def emit(self, record):
if hasattr(record, 'request'): if hasattr(record, 'request'):
@ -208,8 +220,6 @@ class DjangoSocketHandler(_SocketHandler):
return super().emit(record) return super().emit(record)
default_handler = ['socket'] if DEBUG else ['console']
#
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
@ -233,7 +243,7 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
}, },
'socket': { 'socket': {
'level': 'DEBUG', 'level': 'DEBUG',
'class': 'main.settings.DjangoSocketHandler', 'class': f'{ROOT_LOGGER_NAME}.settings.DjangoSocketHandler',
'host': '127.0.0.1', 'host': '127.0.0.1',
'port': 19996, 'port': 19996,
}, },
@ -251,14 +261,3 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
}, },
}, },
} }
# Other Configuration issues
#
DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
LOGIN_URL = 'users-login'
XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')

0
manage.py Executable file → Normal file
View File

2
media

@ -1 +1 @@
Subproject commit abcf63d02e866c3832d014c54f2a95acdfb7d304 Subproject commit 402e8375511470c61021956edad72e1080f51c8e

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

2
pygal

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

View File

@ -1,4 +1,6 @@
Django>=2.0.5 Django
Pillow>=5.4.1 Pillow
python-creole>=1.0.0 disc-id
Whoosh>=2.4.0 pytz
python-creole
Whoosh

@ -1 +1 @@
Subproject commit c1d9cf49c34cc6c97cfb372eec4a30f0188181f9 Subproject commit e1f76d96312e540544b2328d0937b0aa41126aa9

2
themes

@ -1 +1 @@
Subproject commit d3b38d9e7a5d01708380dd9632b0ca7a544a5cef Subproject commit 261ef5048efb4bd204a4ddbe56a90f96cd767ba1

2
users

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