Skip to content

Commit

Permalink
Change display_model_anonymisation to anonymisation_config
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown committed Oct 5, 2023
1 parent 9813106 commit 7032a16
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,22 @@ def get_model_anonymisers() -> list[ModelAnonymiserSummary]:


class Command(BaseCommand):
help = "Display anonymisation configuration" # noqa: A003

def add_arguments(self, parser: Any) -> None:
parser.add_argument(
"-t",
"--template",
default="anonymisation_config.md",
help=(
"Template to use for output (defaults to " "anonymisation_config.md)."
),
)

def handle(self, *args: Any, **options: Any) -> None:
template_name = options["template"]
out = render_to_string(
"anonymiser/display_model_anonymisation.md",
f"anonymiser/{template_name}",
{
"model_anonymisers": get_model_anonymisers(),
"model_fields": registry.get_all_model_fields(),
Expand Down
2 changes: 2 additions & 0 deletions anonymiser/templates/anonymiser/anonymisation_config.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
App,Model,Field,Type,Anonymise,Redact{% for model,fields in model_fields.items %}{% for field in fields %}
{{ field.app_label }},{{ field.model_name }},{{ field.field_name }},{{ field.field_type }},{% if field.is_anonymised %}X{% else %}-{% endif %},{{ field.redaction_strategy|default:"-"|upper }}{% endfor %}{% endfor %}

0 comments on commit 7032a16

Please sign in to comment.