1 # -*- coding: utf-8 -*-
2 # This file is part of EduMed, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.core.management.base import BaseCommand
7 from contact.models import Contact
8 from edumed import contact_forms
11 contact_forms.CooperateForm,
12 contact_forms.ContestForm,
13 contact_forms.WTEMForm,
14 contact_forms.TEMForm,
15 contact_forms.CybernauciForm,
16 contact_forms.WLEMForm,
20 class Command(BaseCommand):
21 help = 'Export contacts for newsletter.'
23 def handle(self, **options):
24 addresses = set(self.get_addresses())
25 for address in addresses:
28 def get_addresses(self):
30 tags = [form.form_tag] + form.old_form_tags
31 contacts = Contact.objects.filter(form_tag__in=tags)
32 for contact in contacts:
33 if contact.body.get(form.mailing_field):