Browse Source

Anonymisation des clubs

Fix_Hash_Check_Very_Old_Passwd
Grizzly 7 years ago
committed by chirac
parent
commit
dd4143dbe2
  1. 13
      users/management/commands/anonymize.py

13
users/management/commands/anonymize.py

@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from users.models import User, School, Adherent from users.models import User, School, Adherent, Club
from django.db.models import F, Value from django.db.models import F, Value
from django.db.models.functions import Concat from django.db.models.functions import Concat
@ -12,11 +12,12 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs): def handle(self, *args, **kwargs):
total = User.objects.count() total = Adherent.objects.count()
self.stdout.write("Starting anonymizing the {} users data.".format(total)) self.stdout.write("Starting anonymizing the {} users data.".format(total))
u = User.objects.all() u = User.objects.all()
a = Adherent.objects.all() a = Adherent.objects.all()
c = Club.objects.all()
self.stdout.write('Supression de l\'école...') self.stdout.write('Supression de l\'école...')
# Create a fake School to put everyone in it. # Create a fake School to put everyone in it.
@ -27,6 +28,7 @@ class Command(BaseCommand):
self.stdout.write('Supression des chambres...') self.stdout.write('Supression des chambres...')
a.update(room=None) a.update(room=None)
c.update(room=None)
self.stdout.write(self.style.SUCCESS('done ...')) self.stdout.write(self.style.SUCCESS('done ...'))
self.stdout.write('Supression des mails...') self.stdout.write('Supression des mails...')
@ -42,7 +44,7 @@ class Command(BaseCommand):
a.update(surname=Concat(Value('surname of '), 'id')) a.update(surname=Concat(Value('surname of '), 'id'))
self.stdout.write(self.style.SUCCESS('done surname')) self.stdout.write(self.style.SUCCESS('done surname'))
a.update(pseudo=F('id')) u.update(pseudo=F('id'))
self.stdout.write(self.style.SUCCESS('done pseudo')) self.stdout.write(self.style.SUCCESS('done pseudo'))
a.update(telephone=Concat(Value('phone of '), 'id')) a.update(telephone=Concat(Value('phone of '), 'id'))
@ -62,9 +64,8 @@ class Command(BaseCommand):
self.stdout.write(self.style.HTTP_NOT_MODIFIED('The password will be: {}'.format(password))) self.stdout.write(self.style.HTTP_NOT_MODIFIED('The password will be: {}'.format(password)))
a.update(pwd_ntlm = hashNT(password)) u.update(pwd_ntlm = hashNT(password))
a.update(password = makeSecret(password)) u.update(password = makeSecret(password))
self.stdout.write(self.style.SUCCESS('done...')) self.stdout.write(self.style.SUCCESS('done...'))
self.stdout.write("Data anonymized!") self.stdout.write("Data anonymized!")

Loading…
Cancel
Save