diff --git a/bsmain/__init__.py b/bsmain/__init__.py index e69de29..b6e6b0f 100644 --- a/bsmain/__init__.py +++ b/bsmain/__init__.py @@ -0,0 +1,16 @@ +from django.core.checks import Warning, register +from django.conf import settings + +from bugsink.app_settings import get_settings + + +@register("bsmain") +def check_no_nested_settings_in_unnested_form(app_configs, **kwargs): + errors = [] + for key in get_settings().keys(): + if hasattr(settings, key): + errors.append(Warning( + f"The setting {key} is defined at the top level of your configuration. It must be nested under the " + f"'BUGSINK' setting." + )) + return errors diff --git a/snappea/__init__.py b/snappea/__init__.py index 8cc0314..48aafda 100644 --- a/snappea/__init__.py +++ b/snappea/__init__.py @@ -1,7 +1,13 @@ +from django.core.checks import Warning, register + import uuid import logging import threading +from django.conf import settings as django_settings # this _must_ be renamed, because we have a settings.py file + +from snappea.settings import get_settings + logger = logging.getLogger("snappea.foreman") @@ -48,3 +54,15 @@ registry = Registry() localStorage = threading.local() localStorage.uuid = str(uuid.uuid4()) thread_uuid = localStorage.uuid + + +@register("snappea") +def check_no_nested_settings_in_unnested_form(app_configs, **kwargs): + errors = [] + for key in get_settings().keys(): + if hasattr(django_settings, key): + errors.append(Warning( + f"The setting {key} is defined at the top level of your configuration. It must be nested under the " + f"'SNAPPEA' setting." + )) + return errors