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):
11 return # typo would be disastrous
15 query = Contact.objects.filter(form_tag='wlem').order_by('-created_at')
17 query = query.filter(pk__in=ids)
19 for wlem_contact in query:
20 if not Submission.objects.filter(email=wlem_contact.contact).exists():
21 first_name, last_name = wlem_contact.body['nazwisko'].split()
23 'email': wlem_contact.contact,
24 'first_name': first_name,
25 'last_name': last_name,
27 Submission.create(**args)
30 self.stdout.write('skipping ' + wlem_contact.contact + ': already exists.')
33 self.stdout.write('New: ' + str(new) + ', skipped: ' + str(skipped))