Skip to content

Commit

Permalink
Fix bug in is_field_redaction_auto
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown committed Sep 30, 2023
1 parent e1b68d5 commit f6cbc52
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions anonymiser/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ def is_field_redaction_auto(self, field: models.Field) -> bool:
return False
if field.name in self.auto_redact_exclude:
return False
if field.primary_key:
if field.is_relation:
return False
if field.choices:
if getattr(field, "primary_key", False):
return False
if getattr(field, "choices", []):
return False
if isinstance(field, models.UUIDField):
return self.auto_redact
Expand All @@ -176,6 +178,7 @@ def is_field_redaction_auto(self, field: models.Field) -> bool:

def is_field_redaction_custom(self, field: models.Field) -> bool:
"""Return True if the field has custom redaction."""
field.choices
return field.name in self.custom_field_redactions

def is_field_redacted(self, field: models.Field) -> bool:
Expand Down

0 comments on commit f6cbc52

Please sign in to comment.