stage2 - keys and emails
[edumed.git] / stage2 / management / commands / stage2_generate_keys.py
1 # -*- coding: utf-8 -*-
2 from django.core.management.base import BaseCommand
3
4 from stage2.models import Participant
5 from wtem.management.commands.wtem_send_results import minimum, get_submissions
6
7
8 class Command(BaseCommand):
9
10     def handle(self, **options):
11         new = 0
12         skipped = 0
13         for s in get_submissions():
14             if s.final_result >= minimum:
15                 if not Participant.objects.filter(email=s.email).exists():
16                     Participant.create(s.first_name, s.last_name, s.email, contact=s.contact)
17                     new += 1
18                 else:
19                     self.stdout.write('skipping ' + s.email + ': already exists.')
20                     skipped += 1
21
22         self.stdout.write('New: ' + str(new) + ', skipped: ' + str(skipped))