Compare commits

...

2 commits

Author SHA1 Message Date
358a27b737
feat: Update pix360core repository URL
Migrated the source for pix360core from `kumig.it` to `git.private.coffee` to align with updated hosting arrangements. This change ensures our project dependencies are fetched from the most current and secure source repository, maintaining the integrity and reliability of our application's external dependencies.
2024-04-13 08:47:25 +02:00
c8332109bb
refactor(settings): improve readability and code consistency
This commit enhances the readability of the settings.py file by formatting lists and dictionary entries across multiple lines, and aligns the usage of quotation marks to ensure consistency (' to "). It simplifies the STATICFILES_DIRS and removes unnecessary whitespace, making the file cleaner and more maintainable. Additionally, it consolidates AUTH_PASSWORD_VALIDATORS to eliminate duplication. These changes not only make the codebase more uniform but also improve the configuration management process by making the settings easier to navigate and modify. Moreover, it adjusts the database configuration setup for MySQL/MariaDB and SQLite to use consistent dict key quotes, aiding in the clarity and readability of database configuration blocks. This effort streamlines future development and debugging by providing a more structured and intuitive settings file.

No specific issues are addressed directly in this commit, but it lays the groundwork for a more maintainable and error-free codebase.
2024-04-12 11:59:40 +02:00
2 changed files with 27 additions and 26 deletions

View file

@ -14,10 +14,14 @@ CONFIG = ASK.config
SECRET_KEY = ASK.secret_key SECRET_KEY = ASK.secret_key
DEBUG = CONFIG.getboolean("PIX360", "Debug", fallback=False) DEBUG = CONFIG.getboolean("PIX360", "Debug", fallback=False)
ALLOWED_HOSTS = [h.strip() for h in CONFIG.get("PIX360", "Hosts", fallback="localhost").split(",")] ALLOWED_HOSTS = [
h.strip() for h in CONFIG.get("PIX360", "Hosts", fallback="localhost").split(",")
]
CSRF_TRUSTED_ORIGINS = [f"https://{h}" for h in ALLOWED_HOSTS] CSRF_TRUSTED_ORIGINS = [f"https://{h}" for h in ALLOWED_HOSTS]
SECURE_PROXY_SSL_HEADER_NAME = CONFIG.get("KEYLOG", "SSLHeaderName", fallback="HTTP_X_FORWARDED_PROTO") SECURE_PROXY_SSL_HEADER_NAME = CONFIG.get(
"KEYLOG", "SSLHeaderName", fallback="HTTP_X_FORWARDED_PROTO"
)
SECURE_PROXY_SSL_HEADER_VALUE = CONFIG.get("KEYLOG", "SSLHeaderValue", fallback="https") SECURE_PROXY_SSL_HEADER_VALUE = CONFIG.get("KEYLOG", "SSLHeaderValue", fallback="https")
SECURE_PROXY_SSL_HEADER = (SECURE_PROXY_SSL_HEADER_NAME, SECURE_PROXY_SSL_HEADER_VALUE) SECURE_PROXY_SSL_HEADER = (SECURE_PROXY_SSL_HEADER_NAME, SECURE_PROXY_SSL_HEADER_VALUE)
@ -31,7 +35,6 @@ INSTALLED_APPS = [
"django.contrib.sessions", "django.contrib.sessions",
"django.contrib.messages", "django.contrib.messages",
"django.contrib.staticfiles", "django.contrib.staticfiles",
"pix360core", "pix360core",
] ]
@ -71,21 +74,21 @@ WSGI_APPLICATION = "pix360.wsgi.application"
if (dbtype := "MySQL") in CONFIG or (dbtype := "MariaDB") in CONFIG: if (dbtype := "MySQL") in CONFIG or (dbtype := "MariaDB") in CONFIG:
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.db.backends.mysql', "ENGINE": "django.db.backends.mysql",
'NAME': CONFIG.get(dbtype, "Database"), "NAME": CONFIG.get(dbtype, "Database"),
'USER': CONFIG.get(dbtype, "Username"), "USER": CONFIG.get(dbtype, "Username"),
'PASSWORD': CONFIG.get(dbtype, "Password"), "PASSWORD": CONFIG.get(dbtype, "Password"),
'HOST': CONFIG.get(dbtype, "Host", fallback="localhost"), "HOST": CONFIG.get(dbtype, "Host", fallback="localhost"),
'PORT': CONFIG.getint(dbtype, "Port", fallback=3306) "PORT": CONFIG.getint(dbtype, "Port", fallback=3306),
} }
} }
else: else:
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.db.backends.sqlite3', "ENGINE": "django.db.backends.sqlite3",
'NAME': BASE_DIR / 'db.sqlite3', "NAME": BASE_DIR / "db.sqlite3",
} }
} }
@ -112,7 +115,7 @@ AUTH_PASSWORD_VALIDATORS = [
if "OIDC" in CONFIG: if "OIDC" in CONFIG:
AUTHENTICATION_BACKENDS = [ AUTHENTICATION_BACKENDS = [
'pix360core.backends.OIDCBackend', "pix360core.backends.OIDCBackend",
] ]
LOGIN_URL = reverse_lazy("oidc_authentication_init") LOGIN_URL = reverse_lazy("oidc_authentication_init")
@ -133,16 +136,16 @@ if "OIDC" in CONFIG:
AUTH_PASSWORD_VALIDATORS = [ AUTH_PASSWORD_VALIDATORS = [
{ {
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
}, },
{ {
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
}, },
] ]
@ -170,15 +173,13 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/ # https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = "/static/"
STATIC_ROOT = None if DEBUG else CONFIG.get( STATIC_ROOT = None if DEBUG else CONFIG.get("PIX360", "StaticRoot", fallback=None)
"PIX360", "StaticRoot", fallback=None)
CORE_STATIC_DIR = Path(pix360core.__file__).parent / "static" CORE_STATIC_DIR = Path(pix360core.__file__).parent / "static"
STATICFILES_DIRS = [ STATICFILES_DIRS = []
]
# Settings for uploaded files # Settings for uploaded files
@ -186,8 +187,8 @@ MEDIA_URL = "/media/"
MEDIA_ROOT = CONFIG.get("PIX360", "MediaRoot", fallback=BASE_DIR / "media") MEDIA_ROOT = CONFIG.get("PIX360", "MediaRoot", fallback=BASE_DIR / "media")
if "S3" in CONFIG: if "S3" in CONFIG:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3StaticStorage' STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
AWS_ACCESS_KEY_ID = CONFIG.get("S3", "AccessKey") AWS_ACCESS_KEY_ID = CONFIG.get("S3", "AccessKey")
AWS_SECRET_ACCESS_KEY = CONFIG.get("S3", "SecretKey") AWS_SECRET_ACCESS_KEY = CONFIG.get("S3", "SecretKey")
AWS_STORAGE_BUCKET_NAME = CONFIG.get("S3", "Bucket") AWS_STORAGE_BUCKET_NAME = CONFIG.get("S3", "Bucket")

View file

@ -7,4 +7,4 @@ argon2-cffi
django-autosecretkey django-autosecretkey
git+https://kumig.it/kumisystems/pix360core.git git+https://git.private.coffee/kumisystems/pix360core.git