X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/000e4c425eb0f65533002e29e5b1b6ae1e60a77f..243f4c5eef6c3f1d6e6d2875080e5830cf5382a8:/wtem/management/commands/wtem_generate_keys.py diff --git a/wtem/management/commands/wtem_generate_keys.py b/wtem/management/commands/wtem_generate_keys.py index 1496c7b..48cd8b2 100644 --- a/wtem/management/commands/wtem_generate_keys.py +++ b/wtem/management/commands/wtem_generate_keys.py @@ -10,15 +10,12 @@ class Command(BaseCommand): new = 0 skipped = 0 - for confirmation in Confirmation.objects.all(): - if not Submission.objects.filter(email=confirmation.email).exists(): - args = {} - for attr in ['first_name', 'last_name', 'email', 'contact']: - args[attr] = getattr(confirmation, attr) - Submission.create(**args) - new += 1 - else: - self.stdout.write('skipping ' + confirmation.email + ': already exists.') - skipped += 1 + emails = list(Submission.objects.values_list('email', flat=True)) + for confirmation in Confirmation.objects.exclude(email__in=emails): + args = {} + for attr in ['first_name', 'last_name', 'email', 'contact']: + args[attr] = getattr(confirmation, attr) + Submission.create(**args) + new += 1 self.stdout.write('New: ' + str(new) + ', skipped: ' + str(skipped))