Commit c0062b4c authored by Joren Vrancken's avatar Joren Vrancken
Browse files

Merge branch 'fix/dataminimisation' into 'master'

Data minimisation

See merge request !1185
parents 2a264c69 bb29b924
...@@ -173,8 +173,8 @@ def execute_data_minimisation(dry_run=False): ...@@ -173,8 +173,8 @@ def execute_data_minimisation(dry_run=False):
:return: list of processed members :return: list of processed members
""" """
members = (Member.objects members = (Member.objects
.filter(Q(membership__until__isnull=False) | .exclude(Q(membership__until__isnull=True) |
Q(membership__until__lte=timezone.now().date())) Q(membership__until__gt=timezone.now().date()))
.distinct() .distinct()
.prefetch_related('membership_set', 'profile')) .prefetch_related('membership_set', 'profile'))
deletion_period = timezone.now().date() - timezone.timedelta(days=31) deletion_period = timezone.now().date() - timezone.timedelta(days=31)
......
...@@ -275,3 +275,26 @@ class DataMinimisationTest(TestCase): ...@@ -275,3 +275,26 @@ class DataMinimisationTest(TestCase):
self.membership.save() self.membership.save()
processed = services.execute_data_minimisation(True) processed = services.execute_data_minimisation(True)
self.assertEqual(len(processed), 0) 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