mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
18423 review changes
This commit is contained in:
parent
7ac9bd9a3d
commit
af6f41d8e6
@ -10,6 +10,7 @@ from django.urls import reverse
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from ..choices import ManagedFileRootPathChoices
|
from ..choices import ManagedFileRootPathChoices
|
||||||
|
from extras.storage import ScriptFileSystemStorage
|
||||||
from netbox.models.features import SyncedDataMixin
|
from netbox.models.features import SyncedDataMixin
|
||||||
from utilities.querysets import RestrictedQuerySet
|
from utilities.querysets import RestrictedQuerySet
|
||||||
|
|
||||||
@ -78,10 +79,14 @@ class ManagedFile(SyncedDataMixin, models.Model):
|
|||||||
return os.path.join(self._resolve_root_path(), self.file_path)
|
return os.path.join(self._resolve_root_path(), self.file_path)
|
||||||
|
|
||||||
def _resolve_root_path(self):
|
def _resolve_root_path(self):
|
||||||
return {
|
storage = self.get_storage
|
||||||
'scripts': settings.SCRIPTS_ROOT,
|
if isinstance(storage, ScriptFileSystemStorage):
|
||||||
'reports': settings.REPORTS_ROOT,
|
return {
|
||||||
}[self.file_root]
|
'scripts': settings.SCRIPTS_ROOT,
|
||||||
|
'reports': settings.REPORTS_ROOT,
|
||||||
|
}[self.file_root]
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
def sync_data(self):
|
def sync_data(self):
|
||||||
if self.data_file:
|
if self.data_file:
|
||||||
|
@ -75,6 +75,7 @@ AUTH_PASSWORD_VALIDATORS = getattr(configuration, 'AUTH_PASSWORD_VALIDATORS', [
|
|||||||
BASE_PATH = trailing_slash(getattr(configuration, 'BASE_PATH', ''))
|
BASE_PATH = trailing_slash(getattr(configuration, 'BASE_PATH', ''))
|
||||||
CHANGELOG_SKIP_EMPTY_CHANGES = getattr(configuration, 'CHANGELOG_SKIP_EMPTY_CHANGES', True)
|
CHANGELOG_SKIP_EMPTY_CHANGES = getattr(configuration, 'CHANGELOG_SKIP_EMPTY_CHANGES', True)
|
||||||
CENSUS_REPORTING_ENABLED = getattr(configuration, 'CENSUS_REPORTING_ENABLED', True)
|
CENSUS_REPORTING_ENABLED = getattr(configuration, 'CENSUS_REPORTING_ENABLED', True)
|
||||||
|
CONFIG_STORAGES = getattr(configuration, 'STORAGES', {})
|
||||||
CORS_ORIGIN_ALLOW_ALL = getattr(configuration, 'CORS_ORIGIN_ALLOW_ALL', False)
|
CORS_ORIGIN_ALLOW_ALL = getattr(configuration, 'CORS_ORIGIN_ALLOW_ALL', False)
|
||||||
CORS_ORIGIN_REGEX_WHITELIST = getattr(configuration, 'CORS_ORIGIN_REGEX_WHITELIST', [])
|
CORS_ORIGIN_REGEX_WHITELIST = getattr(configuration, 'CORS_ORIGIN_REGEX_WHITELIST', [])
|
||||||
CORS_ORIGIN_WHITELIST = getattr(configuration, 'CORS_ORIGIN_WHITELIST', [])
|
CORS_ORIGIN_WHITELIST = getattr(configuration, 'CORS_ORIGIN_WHITELIST', [])
|
||||||
@ -178,7 +179,6 @@ SESSION_COOKIE_SECURE = getattr(configuration, 'SESSION_COOKIE_SECURE', False)
|
|||||||
SESSION_FILE_PATH = getattr(configuration, 'SESSION_FILE_PATH', None)
|
SESSION_FILE_PATH = getattr(configuration, 'SESSION_FILE_PATH', None)
|
||||||
STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None)
|
STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None)
|
||||||
STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {})
|
STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {})
|
||||||
STORAGES = getattr(configuration, 'STORAGES', None)
|
|
||||||
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
|
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
|
||||||
TRANSLATION_ENABLED = getattr(configuration, 'TRANSLATION_ENABLED', True)
|
TRANSLATION_ENABLED = getattr(configuration, 'TRANSLATION_ENABLED', True)
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ DATABASES = {
|
|||||||
#
|
#
|
||||||
|
|
||||||
if STORAGE_BACKEND is not None:
|
if STORAGE_BACKEND is not None:
|
||||||
if STORAGES is not None:
|
if not CONFIG_STORAGES:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"STORAGE_BACKEND and STORAGES are both set, remove the deprecated STORAGE_BACKEND setting."
|
"STORAGE_BACKEND and STORAGES are both set, remove the deprecated STORAGE_BACKEND setting."
|
||||||
)
|
)
|
||||||
@ -251,18 +251,18 @@ if STORAGE_CONFIG is not None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Default STORAGES for Django
|
# Default STORAGES for Django
|
||||||
if STORAGES is None:
|
STORAGES = {
|
||||||
STORAGES = {
|
"default": {
|
||||||
"default": {
|
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
||||||
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
},
|
||||||
},
|
"staticfiles": {
|
||||||
"staticfiles": {
|
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
||||||
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
},
|
||||||
},
|
"scripts": {
|
||||||
"scripts": {
|
"BACKEND": "extras.storage.ScriptFileSystemStorage",
|
||||||
"BACKEND": "extras.storage.ScriptFileSystemStorage",
|
},
|
||||||
},
|
}
|
||||||
}
|
STORAGES.update(CONFIG_STORAGES)
|
||||||
|
|
||||||
# TODO: This code is deprecated and needs to be removed in the future
|
# TODO: This code is deprecated and needs to be removed in the future
|
||||||
if STORAGE_BACKEND is not None:
|
if STORAGE_BACKEND is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user