File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -113,15 +113,13 @@ def anonymize(self, commit=True):
113
113
if commit:
114
114
self.save()
115
115
"""
116
+ signals .anonymize .send (sender = self .__class__ , instance = self )
116
117
self .email = None
117
118
self .first_name = ""
118
119
self .last_name = ""
119
120
update_fields = ["email" , "first_name" , "last_name" ]
120
121
if commit :
121
122
self .save (update_fields = update_fields )
122
- signals .anonymize .send (
123
- sender = self .__class__ , instance = self , update_fields = tuple (update_fields )
124
- )
125
123
return update_fields
126
124
127
125
Original file line number Diff line number Diff line change 4
4
"""
5
5
Signal that is emitted when a user and all their data should be anonymized.
6
6
7
+ The signal is emitted before the private date is delete on the instance,
8
+ thus the receiver can still access the data. The receiver should usually
9
+ not alter the instance, but only later related data. We recommend overriding
10
+ the anonymize method to modify the instance.
11
+
7
12
Usage::
8
13
9
14
from django.dispatch import receiver
12
17
13
18
14
19
@receiver(anonymize, sender=EmailUser)
15
- def anonymize_user(sender, instance, update_fields, **kwargs):
20
+ def anonymize_user(sender, instance, **kwargs):
16
21
# Do something with related user data
17
22
instance.related_model.delete()
18
23
You can’t perform that action at this time.
0 commit comments