From d6e48977349f2bdb78a6114796fbecd8c4b97d90 Mon Sep 17 00:00:00 2001 From: Hugo Rodger-Brown Date: Wed, 27 Sep 2023 12:00:17 +0300 Subject: [PATCH] Fix bug in display output --- anonymiser/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/anonymiser/models.py b/anonymiser/models.py index e043800..5efac38 100644 --- a/anonymiser/models.py +++ b/anonymiser/models.py @@ -133,12 +133,15 @@ def is_field_redaction_auto(self, field: models.Field) -> bool: """ Return True if the field should be auto-redacted. + Return False if the class-level auto_redact attr is False. + Currently this includes text fields that are not choices, primary keys, unique fields, or in the auto_redact_exclude list. """ return ( - isinstance(field, (models.CharField, models.TextField)) + self.auto_redact + and isinstance(field, (models.CharField, models.TextField)) and not field.choices and not field.primary_key and not getattr(field, "unique", False)