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.OlimpiadaForm,
 
  15 class Command(BaseCommand):
 
  16     help = 'Export contacts for newsletter.'
 
  18     def handle(self, **options):
 
  19         addresses = set(self.get_addresses())
 
  20         for address in addresses:
 
  23     def get_addresses(self):
 
  25             tags = [form.form_tag] + form.old_form_tags
 
  26             contacts = Contact.objects.filter(form_tag__in=tags)
 
  27             for contact in contacts:
 
  28                 if contact.body.get(form.mailing_field):