diff --git a/aleksis/core/apps.py b/aleksis/core/apps.py index 908dbc5abaf75af0274edd6aedbe4c5bd2427a9b..bdfe3e3cb311a7b8717f5f9723820d7a81f3fd40 100644 --- a/aleksis/core/apps.py +++ b/aleksis/core/apps.py @@ -7,6 +7,7 @@ from django.http import HttpRequest from django.utils.module_loading import autodiscover_modules from dynamic_preferences.registries import preference_models +from health_check.plugins import plugin_dir from .registries import ( group_preferences_registry, @@ -52,6 +53,10 @@ class CoreConfig(AppConfig): self._refresh_authentication_backends() + from .health_checks import DataChecksHealthCheckBackend + + plugin_dir.register(DataChecksHealthCheckBackend) + @classmethod def _refresh_authentication_backends(cls): """Refresh config list of enabled authentication backends.""" diff --git a/aleksis/core/health_checks.py b/aleksis/core/health_checks.py new file mode 100644 index 0000000000000000000000000000000000000000..e3239087a17e5fed6c59441e9c6a219e86deb006 --- /dev/null +++ b/aleksis/core/health_checks.py @@ -0,0 +1,18 @@ +from django.utils.translation import gettext as _ + +from health_check.backends import BaseHealthCheckBackend + +from aleksis.core.models import DataCheckResult + + +class DataChecksHealthCheckBackend(BaseHealthCheckBackend): + """Checks whether there are unresolved data problems.""" + + critical_service = False + + def check_status(self): + if DataCheckResult.objects.filter(solved=False).exists(): + self.add_error(_("There are unresolved data problems.")) + + def identifier(self): + return self.__class__.__name__