diff --git a/aleksis/core/data_checks.py b/aleksis/core/data_checks.py index d73163ac8dceb90ec695402d959dbf3c04172295..bf823ccc929cb2b0925f118743f87d7625985817 100644 --- a/aleksis/core/data_checks.py +++ b/aleksis/core/data_checks.py @@ -1,5 +1,6 @@ import logging +from django.contrib.contenttypes.models import ContentType from django.db.models.aggregates import Count from django.utils.translation import gettext as _ @@ -44,6 +45,16 @@ class DataCheck: with reversion.create_revision(): cls.solve_options[solve_option].solve(check_result) + @classmethod + def register_result(cls, instance) -> "DataCheckResult": + from aleksis.core.models import DataCheckResult + + ct = ContentType.objects.get_for_model(instance) + result = DataCheckResult.objects.get_or_create( + check=cls.name, content_type=ct, object_id=instance.id + ) + return result + class DataCheckRegistry: def __init__(self):