0001-agendas-anonymize-booking-according-to-event-date-49.patch
chrono/agendas/management/commands/anonymize_bookings.py | ||
---|---|---|
29 | 29 |
def handle(self, **options): |
30 | 30 |
bookings_to_anonymize = Booking.objects.filter( |
31 | 31 |
anonymization_datetime__isnull=True, |
32 |
creation_datetime__lt=timezone.now() - timedelta(days=1) * F('event__agenda__anonymize_delay'), |
|
32 |
event__start_datetime__lt=timezone.now() |
|
33 |
- timedelta(days=1) * F('event__agenda__anonymize_delay'), |
|
33 | 34 |
) |
34 | 35 | |
35 | 36 |
bookings_to_anonymize.update( |
chrono/agendas/models.py | ||
---|---|---|
160 | 160 |
null=True, |
161 | 161 |
blank=True, |
162 | 162 |
validators=[MinValueValidator(30), MaxValueValidator(1000)], |
163 |
help_text=_('After this delay, user data contained in bookings will be pruned.'),
|
|
163 |
help_text=_('User data will be kept for the specified number of days passed the booking date.'),
|
|
164 | 164 |
) |
165 | 165 |
real_agendas = models.ManyToManyField( |
166 | 166 |
'self', |
tests/test_agendas.py | ||
---|---|---|
1577 | 1577 |
day = datetime.datetime(year=2020, month=1, day=1) |
1578 | 1578 |
freezer.move_to(day) |
1579 | 1579 |
agenda = Agenda.objects.create(label='Agenda', kind='events') |
1580 |
event = Event.objects.create(agenda=agenda, start_datetime=now(), places=10, label='Event') |
|
1580 |
event = Event.objects.create( |
|
1581 |
agenda=agenda, start_datetime=now() + datetime.timedelta(days=10), places=10, label='Event' |
|
1582 |
) |
|
1581 | 1583 | |
1582 | 1584 |
for i in range(5): |
1583 | 1585 |
Booking.objects.create( |
... | ... | |
1602 | 1604 |
agenda.anonymize_delay = 100 |
1603 | 1605 |
agenda.save() |
1604 | 1606 | |
1607 |
call_command('anonymize_bookings') |
|
1608 |
# bookings were placed more than 100 days ago but event was only 90 days ago |
|
1609 |
assert not Booking.objects.filter(anonymization_datetime__isnull=False).exists() |
|
1610 | ||
1611 |
freezer.move_to(day + datetime.timedelta(days=111)) |
|
1605 | 1612 |
call_command('anonymize_bookings') |
1606 | 1613 |
assert ( |
1607 | 1614 |
Booking.objects.filter( |
1608 |
- |