django_lib update

This commit is contained in:
Dirk Alders 2024-10-10 13:01:42 +02:00
parent 69da610a0b
commit d9228b68f2
6 changed files with 98 additions and 93 deletions

View File

@ -1,20 +1,32 @@
#######################################################################
# Configuration of your django application
#######################################################################
#
# General settings
# Users library
#
# This enables or disables the self registration
USERS_SELF_REGISTRATION = False
# APP_NAME is used for logging
APP_NAME = 'patt'
#
# Themes library
#
# This defines the default theme, if no theme is set in the django parameters
DEFAULT_THEME = 'clear-green'
#
# Django
#
# This defines the mode of the running server
# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = False
DEBUG = False
# SECURITY WARNING: don't run with a dummy secret in production!
# SECRET_KEY = None
# 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 = ['127.0.0.1', ]
# ALLOWED_HOSTS = ['<YOUR_SERVER_HOSTNAME>', ]
#
# Style settings
#
# DEFAULT_THEME = 'clear-green'
# This might be needed for usage in a docker environment
# CSRF_TRUSTED_ORIGINS = ['<YOUR_SERVER_URL>', ]

View File

@ -1,78 +1,39 @@
"""
Django settings for this project.
Django settings for patt 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
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
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
from pathlib import Path
import config
from logging.handlers import SocketHandler as _SocketHandler
import os
import random
import stat
import sys
import random
try:
from config import APP_NAME as ROOT_LOGGER_NAME
except ImportError:
ROOT_LOGGER_NAME = 'root'
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# 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,
'DEFAULT_THEME': 'clear-green',
'ALLOWED_HOSTS': ['127.0.0.1', ],
'CSRF_TRUSTED_ORIGINS': [],
}
# 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
# See https://docs.djangoproject.com/en/3.0/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
#
INSTALLED_APPS = [
'patt.apps.PattConfig',
'themes.apps.ThemesConfig',
'users.apps.UsersConfig',
'mycreole.apps.MycreoleConfig',
'users.apps.UsersConfig',
#
'django.contrib.admin',
'django.contrib.auth',
@ -118,19 +79,19 @@ WSGI_APPLICATION = 'main.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
#
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# 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 = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
@ -147,14 +108,9 @@ AUTH_PASSWORD_VALIDATORS = [
]
# Search Engine
#
WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
#
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGES = [
('en', 'English'),
@ -176,10 +132,9 @@ USE_TZ = True
# 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_URL = '/static/'
STATIC_URL = 'static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
MEDIA_URL = '/media/'
@ -189,18 +144,67 @@ MYCREOLE_ATTACHMENT_ACCESS = {
'read': 'patt.access.read_attachment',
'modify': 'patt.access.modify_attachment',
}
MYCREOLE_BAR = {
'navibar': 'patt.context.navigationbar',
'menubar': 'patt.context.menubar',
}
MYCREOLE_EXT_FILTERS = [
'patt.creole.task_link_filter',
'patt.creole.tasklist_link_filter',
]
# Session parameters
WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
LOGIN_URL = 'users-login'
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Check permission of config.py
#
PERSISTENT_SESSION_VARIABLES = []
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,
'DEFAULT_THEME': 'clear-green',
'ALLOWED_HOSTS': ['127.0.0.1', 'localhost', ],
'CSRF_TRUSTED_ORIGINS': [],
}
# 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
#
ROOT_LOGGER_NAME = os.path.basename(os.path.dirname(__file__))
default_handler = ['socket'] if DEBUG else ['console']
class DjangoSocketHandler(_SocketHandler):
def emit(self, record):
if hasattr(record, 'request'):
@ -208,8 +212,6 @@ class DjangoSocketHandler(_SocketHandler):
return super().emit(record)
default_handler = ['socket'] if DEBUG else ['console']
#
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
@ -233,7 +235,7 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
},
'socket': {
'level': 'DEBUG',
'class': 'main.settings.DjangoSocketHandler',
'class': f'{ROOT_LOGGER_NAME}.settings.DjangoSocketHandler',
'host': '127.0.0.1',
'port': 19996,
},
@ -251,12 +253,3 @@ File "%(pathname)s", line %(lineno)d, in %(funcName)s
},
},
}
# Other Configuration issues
#
LOGIN_URL = 'users-login'
# Default Auto Filed
#
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

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

2
patt

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

2
themes

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

2
users

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