1 # -*- coding: utf-8 -*-
2 from django.core.management.base import BaseCommand
4 from contact.models import Contact
5 from wtem.models import Submission
8 class Command(BaseCommand):
10 def handle(self, *ids, **options):
14 query = Contact.objects.filter(form_tag='wlem').order_by('-created_at')
16 query = query.filter(pk__in=ids)
18 for wlem_contact in query:
19 if not Submission.objects.filter(email=wlem_contact.contact).exists():
20 first_name, last_name = wlem_contact.body['nazwisko'].split()
22 'email': wlem_contact.contact,
23 'first_name': first_name,
24 'last_name': last_name,
26 Submission.create(**args)
29 self.stdout.write('skipping ' + wlem_contact.contact + ': already exists.')
32 self.stdout.write('New: ' + str(new) + ', skipped: ' + str(skipped))