update emails for stage2
[edumed.git] / wtem / management / commands / wtem_generate_keys.py
1 # -*- coding: utf-8 -*-
2 from django.core.management.base import BaseCommand
3
4 from wtem.models import Submission, Confirmation
5
6
7 class Command(BaseCommand):
8
9     def handle(self, **options):
10         new = 0
11         skipped = 0
12
13         emails = list(Submission.objects.values_list('email', flat=True))
14         for confirmation in Confirmation.objects.exclude(email__in=emails):
15             args = {}
16             for attr in ['first_name', 'last_name', 'email', 'contact']:
17                 args[attr] = getattr(confirmation, attr)
18             Submission.create(**args)
19             new += 1
20
21         self.stdout.write('New: ' + str(new) + ', skipped: ' + str(skipped))