Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor data minimization methods #3114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions website/events/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from events.services import execute_data_minimisation


class EventsConfig(AppConfig):
"""AppConfig for the events package."""
Expand All @@ -16,6 +18,9 @@ def ready(self):

register()

def data_minimization_methods(self):
return {"events": execute_data_minimisation}

def menu_items(self):
return {
"categories": [{"name": "association", "title": "Association", "key": 1}],
Expand Down
5 changes: 5 additions & 0 deletions website/facedetection/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

from facedetection.services import execute_data_minimisation


class FaceDetectionConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
Expand All @@ -11,3 +13,6 @@ def ready(self):
"""Register signals when the app is ready."""
# pylint: disable=unused-import,import-outside-toplevel
from . import signals # noqa

def data_minimization_methods(self):
return {"facedetection": execute_data_minimisation}
5 changes: 5 additions & 0 deletions website/members/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from members.services import execute_data_minimisation


class MembersConfig(AppConfig):
name = "members"
verbose_name = _("Members")

def data_minimization_methods(self):
return {"members": execute_data_minimisation}

def menu_items(self):
return {
"categories": [{"name": "members", "title": "For Members", "key": 2}],
Expand Down
5 changes: 5 additions & 0 deletions website/payments/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

from payments.services import execute_data_minimisation


class PaymentsConfig(AppConfig):
"""AppConfig for the payments package."""

name = "payments"
verbose_name = _("Payments")

def data_minimization_methods(self):
return {"payments": execute_data_minimisation}
5 changes: 5 additions & 0 deletions website/pizzas/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

from pizzas.services import execute_data_minimisation


class PizzasConfig(AppConfig):
"""AppConfig for the pizzas package."""
Expand All @@ -14,3 +16,6 @@ def ready(self):
from .payables import register

register()

def data_minimization_methods(self):
return {"pizzas": execute_data_minimisation}
5 changes: 5 additions & 0 deletions website/sales/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.apps import AppConfig

from pizzas.services import execute_data_minimisation


class SalesConfig(AppConfig):
name = "sales"
Expand All @@ -9,3 +11,6 @@ def ready(self):
from .payables import register

register()

def data_minimization_methods(self):
return {"sales": execute_data_minimisation}
5 changes: 5 additions & 0 deletions website/thaliawebsite/apps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from django.apps import AppConfig
from django.urls import reverse

from utils.snippets import minimise_logentries_data


class ThaliaWebsiteConfig(AppConfig):
name = "thaliawebsite"

def menu_items(self):
return {"items": [{"title": "Home", "url": reverse("index"), "key": 0}]}

def data_minimization_methods(self):
return {"logentries": minimise_logentries_data}
44 changes: 9 additions & 35 deletions website/thaliawebsite/management/commands/dataminimisation.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from django.apps import apps
from django.core.management.base import BaseCommand

from events import services as events_services
from facedetection import services as facedetection_services
from members import services as members_services
from payments import services as payments_services
from pizzas import services as pizzas_services
from sales import services as sales_services
from utils.snippets import minimise_logentries_data


class Command(BaseCommand):
"""This command can be executed periodically to minimise the user information in our database."""
Expand All @@ -22,30 +15,11 @@ def add_arguments(self, parser):
)

def handle(self, *args, **options):
processed = members_services.execute_data_minimisation(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed data for {p}")

processed = events_services.execute_data_minimisation(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed registration information for {p}")

processed = payments_services.execute_data_minimisation(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed payments information for {p}")

processed = pizzas_services.execute_data_minimisation(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed food events information for {p}")

processed = sales_services.execute_data_minimisation(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed sales orders for {p}")

processed = facedetection_services.execute_data_minimisation(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed reference faces: {p}")

processed = minimise_logentries_data(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed user from logentries for {p}")
for app in apps.get_app_configs():
if hasattr(app, "data_minimization_methods"):
data_minimization_methods = app.data_minimization_methods()
for data_type in data_minimization_methods.keys():
method = data_minimization_methods[data_type]
processed = method(options["dry-run"])
for p in processed:
self.stdout.write(f"Removed {data_type} data for {p}")