mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Warn about top-level settings
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user