Commit 1725048e authored by Joren Vrancken's avatar Joren Vrancken Committed by Sébastiaan Versteeg

Merge branch 'fix/dataminimisation' into 'master'

Data minimisation

See merge request !1185

(cherry picked from commit c0062b4c)

490ca8e5 Fix name of management command minimising data
7b919dfb Add tests for failing data minimising code
8435de49 Replace filter by exclude of current members
parent 1a6e3147
......@@ -173,8 +173,8 @@ def execute_data_minimisation(dry_run=False):
:return: list of processed members
"""
members = (Member.objects
.filter(Q(membership__until__isnull=False) |
Q(membership__until__lte=timezone.now().date()))
.exclude(Q(membership__until__isnull=True) |
Q(membership__until__gt=timezone.now().date()))
.distinct()
.prefetch_related('membership_set', 'profile'))
deletion_period = timezone.now().date() - timezone.timedelta(days=31)
......
......@@ -275,3 +275,26 @@ class DataMinimisationTest(TestCase):
self.membership.save()
processed = services.execute_data_minimisation(True)
self.assertEqual(len(processed), 0)
self.membership.until = timezone.now().replace(
year=2018, month=9, day=1)
self.membership.save()
with self.subTest('Newer year membership after expired one'):
m = Membership.objects.create(
user=self.member,
type=Membership.MEMBER,
since=timezone.now().replace(year=2018, month=9, day=10),
until=timezone.now().replace(year=2019, month=8, day=31),
)
processed = services.execute_data_minimisation(True)
self.assertEqual(len(processed), 0)
m.delete()
with self.subTest('Newer study membership after expired one'):
m = Membership.objects.create(
user=self.member,
type=Membership.MEMBER,
since=timezone.now().replace(year=2018, month=9, day=10),
until=None
)
processed = services.execute_data_minimisation(True)
self.assertEqual(len(processed), 0)
m.delete()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment