Commit c9682f3c authored by Flavio TARSETTI's avatar Flavio TARSETTI Committed by Flavio TARSETTI

[accounts] fix supervision track deletion

parent 013e9dab
Pipeline #35963 passed with stage
in 13 minutes and 10 seconds
......@@ -71,8 +71,6 @@ class Command(BaseCommand):
count = 0
for invalid_profile in invalid_userprofiles_new_users:
user = invalid_profile.user
# New user should not have a supervision track - Delete if any
supervisiontracks = SupervisionTrack.objects.filter(supervision_key=invalid_profile.supervision_key)
registration_profile = RegistrationProfile.objects.get(user=invalid_profile.user)
expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)
......@@ -80,14 +78,12 @@ class Command(BaseCommand):
count += 1
user.delete()
invalid_profile.delete()
for supervisiontrack in supervisiontracks:
supervisiontrack.delete()
# New user should not have a supervision track - Delete if any
SupervisionTrack.objects.filter(supervision_key=invalid_profile.supervision_key).delete()
registration_profile.delete()
for invalid_profile in invalid_userprofiles_waiting_validation:
user = invalid_profile.user
# User waiting validation should not have a supervision track - Delete if any
supervisiontracks = SupervisionTrack.objects.filter(supervision_key=invalid_profile.supervision_key)
registration_profile = RegistrationProfile.objects.get(user=invalid_profile.user)
expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR)
......@@ -95,8 +91,8 @@ class Command(BaseCommand):
count += 1
user.delete()
invalid_profile.delete()
for supervisiontrack in supervisiontracks:
supervisiontrack.delete()
# User waiting validation should not have a supervision track - Delete if any
SupervisionTrack.objects.filter(supervision_key=invalid_profile.supervision_key).delete()
registration_profile.delete()
self.stdout.write('{} Invalid user(s) successfully cleaned/'.format(count) + '{} Total user(s) checked'.format(invalid_userprofiles_new_users.count()+invalid_userprofiles_waiting_validation.count()))
......
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