refactor: Standardizes string quotes in settings

Replaces single quotes with double quotes in the settings
file for consistency and clarity.

These changes improve code readability and align with
Python's PEP 8 style guide.
This commit is contained in:
Kumi 2024-11-20 07:43:59 +01:00
parent 725f566d97
commit c0d5e15687
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -25,64 +25,68 @@ try:
ENABLED_MODULES # TODO: Move this to settings.ini ENABLED_MODULES # TODO: Move this to settings.ini
except NameError: except NameError:
ENABLED_MODULES = [ ENABLED_MODULES = [
'cbt', "cbt",
'mood', "mood",
'dreams', "dreams",
'health', "health",
'friends', "friends",
'habits', "habits",
'gpslog', "gpslog",
] ]
CORE_MODULES = [ CORE_MODULES = [
'common', "common",
'frontend', "frontend",
'msgio', "msgio",
'cronhandler', "cronhandler",
] ]
INSTALLED_APPS = [ INSTALLED_APPS = (
'django.contrib.admin', [
'django.contrib.auth', "django.contrib.admin",
'django.contrib.contenttypes', "django.contrib.auth",
'django.contrib.sessions', "django.contrib.contenttypes",
'django.contrib.messages', "django.contrib.sessions",
'django.contrib.staticfiles', "django.contrib.messages",
'colorfield', "django.contrib.staticfiles",
'multiselectfield', "colorfield",
'dbsettings', "multiselectfield",
'mozilla_django_oidc', "dbsettings",
] + CORE_MODULES + ENABLED_MODULES "mozilla_django_oidc",
]
+ CORE_MODULES
+ ENABLED_MODULES
)
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', "django.middleware.security.SecurityMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware', "django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.common.CommonMiddleware', "django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware', "django.middleware.csrf.CsrfViewMiddleware",
'django.contrib.auth.middleware.AuthenticationMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware",
'django.contrib.messages.middleware.MessageMiddleware', "django.contrib.messages.middleware.MessageMiddleware",
'django.middleware.clickjacking.XFrameOptionsMiddleware', "django.middleware.clickjacking.XFrameOptionsMiddleware",
] ]
ROOT_URLCONF = 'kumify.urls' ROOT_URLCONF = "kumify.urls"
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', "BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [], "DIRS": [],
'APP_DIRS': True, "APP_DIRS": True,
'OPTIONS': { "OPTIONS": {
'context_processors': [ "context_processors": [
'django.template.context_processors.debug', "django.template.context_processors.debug",
'django.template.context_processors.request', "django.template.context_processors.request",
'django.contrib.auth.context_processors.auth', "django.contrib.auth.context_processors.auth",
'django.contrib.messages.context_processors.messages', "django.contrib.messages.context_processors.messages",
], ],
}, },
}, },
] ]
WSGI_APPLICATION = 'kumify.wsgi.application' WSGI_APPLICATION = "kumify.wsgi.application"
# Database # Database
@ -90,25 +94,25 @@ WSGI_APPLICATION = 'kumify.wsgi.application'
if "MySQL" in CONFIG_FILE.config: if "MySQL" in CONFIG_FILE.config:
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.contrib.gis.db.backends.mysql', "ENGINE": "django.contrib.gis.db.backends.mysql",
'NAME': CONFIG_FILE.config.get("MySQL", "Database"), "NAME": CONFIG_FILE.config.get("MySQL", "Database"),
'USER': CONFIG_FILE.config.get("MySQL", "Username"), "USER": CONFIG_FILE.config.get("MySQL", "Username"),
'PASSWORD': CONFIG_FILE.config.get("MySQL", "Password"), "PASSWORD": CONFIG_FILE.config.get("MySQL", "Password"),
'HOST': CONFIG_FILE.config.get("MySQL", "Host", fallback="localhost"), "HOST": CONFIG_FILE.config.get("MySQL", "Host", fallback="localhost"),
'PORT': CONFIG_FILE.config.getint("MySQL", "Port", fallback=3306), "PORT": CONFIG_FILE.config.getint("MySQL", "Port", fallback=3306),
'OPTIONS': { "OPTIONS": {
'charset': 'utf8mb4', "charset": "utf8mb4",
'sql_mode': 'traditional', "sql_mode": "traditional",
} },
} }
} }
else: else:
DATABASES = { DATABASES = {
'default': { "default": {
'ENGINE': 'django.contrib.gis.db.backends.spatialite', "ENGINE": "django.contrib.gis.db.backends.spatialite",
'NAME': BASE_DIR / 'db.sqlite3', "NAME": BASE_DIR / "db.sqlite3",
} }
} }
@ -117,35 +121,35 @@ else:
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTHENTICATION_BACKENDS = [ AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend', "django.contrib.auth.backends.ModelBackend",
] ]
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",
}, },
] ]
PASSWORD_HASHERS = [ PASSWORD_HASHERS = [
'django.contrib.auth.hashers.Argon2PasswordHasher', "django.contrib.auth.hashers.Argon2PasswordHasher",
'django.contrib.auth.hashers.PBKDF2PasswordHasher', "django.contrib.auth.hashers.PBKDF2PasswordHasher",
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', "django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher', "django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
] ]
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/ # https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = "en-us"
USE_I18N = True USE_I18N = True
@ -159,17 +163,18 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/ # https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = "/static/"
STATIC_ROOT = None if DEBUG else CONFIG_FILE.config.get( STATIC_ROOT = CONFIG_FILE.config.get(
"KUMIFY", "StaticRoot", fallback=BASE_DIR / "static") "KUMIFY", "StaticRoot", fallback=BASE_DIR / "static"
)
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/" LOGOUT_REDIRECT_URL = "/"
if "S3" in CONFIG_FILE.config: if "S3" in CONFIG_FILE.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_FILE.config.get("S3", "AccessKey") AWS_ACCESS_KEY_ID = CONFIG_FILE.config.get("S3", "AccessKey")
AWS_SECRET_ACCESS_KEY = CONFIG_FILE.config.get("S3", "SecretKey") AWS_SECRET_ACCESS_KEY = CONFIG_FILE.config.get("S3", "SecretKey")
AWS_STORAGE_BUCKET_NAME = CONFIG_FILE.config.get("S3", "Bucket") AWS_STORAGE_BUCKET_NAME = CONFIG_FILE.config.get("S3", "Bucket")
@ -185,25 +190,25 @@ if "OIDC" in CONFIG_FILE.config:
USE_OIDC = True USE_OIDC = True
OIDC_PROVIDER_NAME = CONFIG_FILE.config.get( OIDC_PROVIDER_NAME = CONFIG_FILE.config.get(
"OIDC", "ProviderName", fallback="OpenID Connect") "OIDC", "ProviderName", fallback="OpenID Connect"
)
AUTHENTICATION_BACKENDS.append( AUTHENTICATION_BACKENDS.append("mozilla_django_oidc.auth.OIDCAuthenticationBackend")
'mozilla_django_oidc.auth.OIDCAuthenticationBackend')
OIDC_RP_CLIENT_ID = CONFIG_FILE.config.get("OIDC", "ClientID") OIDC_RP_CLIENT_ID = CONFIG_FILE.config.get("OIDC", "ClientID")
OIDC_RP_CLIENT_SECRET = CONFIG_FILE.config.get("OIDC", "ClientSecret") OIDC_RP_CLIENT_SECRET = CONFIG_FILE.config.get("OIDC", "ClientSecret")
if (opsk := CONFIG_FILE.config.get("OIDC", "OPSignKey", fallback="")): if opsk := CONFIG_FILE.config.get("OIDC", "OPSignKey", fallback=""):
OIDC_RP_SIGN_ALGO = "RS256" OIDC_RP_SIGN_ALGO = "RS256"
OIDC_RP_IDP_SIGN_KEY = opsk OIDC_RP_IDP_SIGN_KEY = opsk
elif (jwks := CONFIG_FILE.config.get("OIDC", "JWKSEndpoint", fallback="")): elif jwks := CONFIG_FILE.config.get("OIDC", "JWKSEndpoint", fallback=""):
OIDC_RP_SIGN_ALGO = "RS256" OIDC_RP_SIGN_ALGO = "RS256"
OIDC_OP_JWKS_ENDPOINT = jwks OIDC_OP_JWKS_ENDPOINT = jwks
OIDC_OP_AUTHORIZATION_ENDPOINT = CONFIG_FILE.config.get( OIDC_OP_AUTHORIZATION_ENDPOINT = CONFIG_FILE.config.get(
"OIDC", "AuthorizationEndpoint") "OIDC", "AuthorizationEndpoint"
)
OIDC_OP_TOKEN_ENDPOINT = CONFIG_FILE.config.get("OIDC", "TokenEndpoint") OIDC_OP_TOKEN_ENDPOINT = CONFIG_FILE.config.get("OIDC", "TokenEndpoint")
OIDC_OP_USER_ENDPOINT = CONFIG_FILE.config.get("OIDC", "UserInfoEndpoint") OIDC_OP_USER_ENDPOINT = CONFIG_FILE.config.get("OIDC", "UserInfoEndpoint")
OIDC_CREATE_USER = CONFIG_FILE.config.get( OIDC_CREATE_USER = CONFIG_FILE.config.get("OIDC", "CreateUsers", fallback=False)
"OIDC", "CreateUsers", fallback=False)