Skip to content

Commit

Permalink
Closes #76: Check for required settings on init
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Sep 5, 2024
1 parent 07904b2 commit 12dc0ae
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions netbox_branching/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

from netbox.plugins import PluginConfig
from netbox.registry import registry

Expand All @@ -23,6 +26,17 @@ class AppConfig(PluginConfig):
def ready(self):
super().ready()
from . import constants, events, search, signal_receivers
from .utilities import DynamicSchemaDict

# Validate required settings
if type(settings.DATABASES) is not DynamicSchemaDict:
raise ImproperlyConfigured(
"netbox_branching: DATABASES must be a DynamicSchemaDict instance."
)
if 'netbox_branching.database.BranchAwareRouter' not in settings.DATABASE_ROUTERS:
raise ImproperlyConfigured(
"netbox_branching: DATABASE_ROUTERS must contain 'netbox_branching.database.BranchAwareRouter'."
)

# Record all object types which support branching in the NetBox registry
if 'branching' not in registry['model_features']:
Expand Down

0 comments on commit 12dc0ae

Please sign in to comment.