1 # -*- coding: utf-8 -*-
2 from django.core.management.base import BaseCommand
4 from wtem.models import Submission, Confirmation
7 class Command(BaseCommand):
9 def handle(self, **options):
13 emails = list(Submission.objects.values_list('email', flat=True))
14 for confirmation in Confirmation.objects.exclude(email__in=emails):
15 if not Submission.objects.filter(email=confirmation.email).exists():
17 for attr in ['first_name', 'last_name', 'email', 'contact']:
18 args[attr] = getattr(confirmation, attr)
19 Submission.create(**args)
22 self.stdout.write('skipping ' + confirmation.email + ': already exists.')
25 self.stdout.write('New: ' + str(new) + ', skipped: ' + str(skipped))