From 062d651632be5443710f0a0f9c3be11be26daec6 Mon Sep 17 00:00:00 2001 From: Ben Dickinson Date: Fri, 7 Jun 2024 12:06:24 +0100 Subject: [PATCH] Add Django system check for settings --- src/wagtail_localize_smartling/apps.py | 3 +++ src/wagtail_localize_smartling/checks.py | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/wagtail_localize_smartling/apps.py b/src/wagtail_localize_smartling/apps.py index 10d7ccf..145e8e0 100644 --- a/src/wagtail_localize_smartling/apps.py +++ b/src/wagtail_localize_smartling/apps.py @@ -6,3 +6,6 @@ class WagtailLocalizeSmartlingAppConfig(AppConfig): label = "wagtail_localize_smartling" name = "wagtail_localize_smartling" verbose_name = "Wagtail Localize Smartling" + + def ready(self): + from . import checks, signals # noqa: F401 diff --git a/src/wagtail_localize_smartling/checks.py b/src/wagtail_localize_smartling/checks.py index 26b9d42..ab88cf4 100644 --- a/src/wagtail_localize_smartling/checks.py +++ b/src/wagtail_localize_smartling/checks.py @@ -1 +1,19 @@ -# TODO check required settings +from django.core.checks import Error, register +from django.core.exceptions import ImproperlyConfigured + +from .settings import settings as smartling_settings + + +@register() +def smartling_settings_check(app_configs, **kwargs): + errors = [] + try: + str(smartling_settings.PROJECT_ID) + except ImproperlyConfigured as e: + errors.append( + Error( + e.args[0], + id="wagtail_localize_smartling.E001", + ) + ) + return errors