Skip to content
Snippets Groups Projects
Verified Commit c8391845 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add custom health check for data checks

parent 79bbb7b7
No related branches found
No related tags found
1 merge request!389Add data check system
Pipeline #4831 passed
......@@ -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."""
......
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__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment