From aebb9bf577a50c3d58f3bf7e9ed666a1f0d19865 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Tue, 1 Jun 2021 18:10:08 +0200
Subject: [PATCH] Use a set for the data check registry to prevent double
 entries

---
 CHANGELOG.rst               | 1 +
 aleksis/core/apps.py        | 4 ++--
 aleksis/core/data_checks.py | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index c4d2d9d6b..b533b0559 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -20,6 +20,7 @@ Fixed
 ~~~~~
 
 * Fix installation documentation (nginx, uWSGI).
+* Use a set for data checks registry to prevent double entries.
 
 Removed
 ~~~~~~~
diff --git a/aleksis/core/apps.py b/aleksis/core/apps.py
index 16d301296..9679c309e 100644
--- a/aleksis/core/apps.py
+++ b/aleksis/core/apps.py
@@ -74,9 +74,9 @@ class CoreConfig(AppConfig):
         """Get all data checks from all loaded models."""
         from aleksis.core.data_checks import DataCheckRegistry
 
-        data_checks = []
+        data_checks = set()
         for model in apps.get_models():
-            data_checks += getattr(model, "data_checks", [])
+            data_checks.update(getattr(model, "data_checks", []))
         DataCheckRegistry.data_checks = data_checks
 
     def preference_updated(
diff --git a/aleksis/core/data_checks.py b/aleksis/core/data_checks.py
index 02d2d7dd1..234c82c0c 100644
--- a/aleksis/core/data_checks.py
+++ b/aleksis/core/data_checks.py
@@ -225,7 +225,7 @@ class DataCheck:
 class DataCheckRegistry:
     """Create central registry for all data checks in AlekSIS."""
 
-    data_checks = []
+    data_checks: set = set()
 
     @classproperty
     def data_checks_by_name(cls):
-- 
GitLab