Add back support for individual database settings

Added for compatibility with version 3.2 settings.

These are now a fallback if the new 'DATABASES'
setting is not specified.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-11-12 15:18:27 -04:00
parent 2e231dad62
commit 4a1607afad
3 changed files with 57 additions and 10 deletions

View File

@@ -134,6 +134,10 @@
- Add document trashed event. Closes GitLab issue #608
Thanks to Vikas Kedia (@vikaskedia) for the report.
- Add transaction handling to document model events.
- Add back support for individual database settings
for compatibility with version 3.2 settings.
These are now a fallback if the new 'DATABASES'
setting is not specified.
3.2.10 (2019-XX-XX)
===================

View File

@@ -9,6 +9,13 @@ BOOTSTRAP_SETTING_LIST = (
{'name': 'COMMON_EXTRA_APPS'},
{'name': 'DATA_UPLOAD_MAX_MEMORY_SIZE'},
{'name': 'DATABASES'},
{'name': 'DATABASE_ENGINE'},
{'name': 'DATABASE_NAME'},
{'name': 'DATABASE_USER'},
{'name': 'DATABASE_PASSWORD'},
{'name': 'DATABASE_HOST'},
{'name': 'DATABASE_PORT'},
{'name': 'DATABASE_CONN_MAX_AGE'},
{'name': 'DEBUG', 'default': 'false'},
{'name': 'DEFAULT_FROM_EMAIL'},
{'name': 'DISALLOWED_USER_AGENTS'},

View File

@@ -328,14 +328,6 @@ SWAGGER_SETTINGS = {
AJAX_REDIRECT_CODE = 278
# ----- Database -----
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(MEDIA_ROOT, 'db.sqlite3'),
}
}
BASE_INSTALLED_APPS = INSTALLED_APPS
COMMON_EXTRA_APPS = ()
COMMON_DISABLED_APPS = ()
@@ -358,9 +350,32 @@ if 'revertsettings' not in sys.argv:
for setting in BOOTSTRAP_SETTING_LIST:
if setting['name'] in configuration_result:
globals().update({setting['name']: configuration_result[setting['name']]})
globals().update(
{setting['name']: configuration_result[setting['name']]}
)
elif setting['name'] in environment_result:
globals().update({setting['name']: environment_result[setting['name']]})
globals().update(
{setting['name']: environment_result[setting['name']]}
)
else:
# Apply the default only if it has not yet been defined previously
# in this module.
if setting['name'] not in globals():
globals().update(
{
setting['name']: get_environment_setting(
name=setting['name']
)
}
)
else:
# Safe fallback to allow the revertsettings command to complete.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(MEDIA_ROOT, 'db.sqlite3'),
}
}
for app in INSTALLED_APPS:
@@ -378,3 +393,24 @@ for APP in (COMMON_EXTRA_APPS or ()):
INSTALLED_APPS = [
APP for APP in INSTALLED_APPS if APP not in (COMMON_DISABLED_APPS or ())
]
if not DATABASES:
if DATABASE_ENGINE:
DATABASES = {
'default': {
'ENGINE': DATABASE_ENGINE,
'NAME': DATABASE_NAME,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'HOST': DATABASE_HOST,
'PORT': DATABASE_PORT,
'CONN_MAX_AGE': DATABASE_CONN_MAX_AGE
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(MEDIA_ROOT, 'db.sqlite3'),
}
}