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