From 11564d8cfc623e14d798d4b220eab27b6a2f740f Mon Sep 17 00:00:00 2001 From: ronardcaktus Date: Thu, 19 Feb 2026 08:06:48 -0500 Subject: [PATCH] Add consent class and test --- analytical/templatetags/matomo.py | 4 ++-- tests/unit/test_tag_matomo.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/analytical/templatetags/matomo.py b/analytical/templatetags/matomo.py index 9107516..4ff6c2e 100644 --- a/analytical/templatetags/matomo.py +++ b/analytical/templatetags/matomo.py @@ -46,8 +46,8 @@ VARIABLE_CODE = ( IDENTITY_CODE = '_paq.push(["setUserId", "%(userid)s"]);' DISABLE_COOKIES_CODE = "_paq.push(['disableCookies']);" -GIVE_CONSENT_CLASS = "matomo_give_consent" -REMOVE_CONSENT_CLASS = "matomo_remove_consent" +GIVE_CONSENT_CLASS = 'matomo_give_consent' +REMOVE_CONSENT_CLASS = 'matomo_remove_consent' ASK_FOR_CONSENT_CODE = """ _paq.push(['requireConsent']); diff --git a/tests/unit/test_tag_matomo.py b/tests/unit/test_tag_matomo.py index 0765c12..c6ebd93 100644 --- a/tests/unit/test_tag_matomo.py +++ b/tests/unit/test_tag_matomo.py @@ -159,3 +159,8 @@ class MatomoTagTestCase(TagTestCase): def test_disable_cookies(self): r = MatomoNode().render(Context({})) assert "_paq.push(['disableCookies']);" in r + + @override_settings(MATOMO_ASK_FOR_CONSENT=True) + def test_ask_for_consent(self): + r = MatomoNode().render(Context({})) + self.assertTrue("_paq.push(['requireConsent']);" in r, r)