forked from beba/foerderbarometer
simplified code
This commit is contained in:
parent
d3f18b0b93
commit
1495621ef0
|
|
@ -1,9 +1,8 @@
|
|||
from datetime import date, timedelta
|
||||
import sys
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.template.loader import get_template
|
||||
from django.core.mail import send_mail, BadHeaderError, EmailMessage
|
||||
from django.core.mail import BadHeaderError
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
from django.conf import settings
|
||||
|
||||
|
|
@ -52,7 +51,7 @@ class Command(BaseCommand):
|
|||
# bcc=[SURVEY_EMAIL])
|
||||
#survey_mail.send(fail_silently=False)
|
||||
except BadHeaderError:
|
||||
return HttpResponse('Invalid header found.')
|
||||
return HttpResponse('Invalid header found.') # FIXME HttpResponse???
|
||||
|
||||
print(f'send surveylinkemail to {email}...')
|
||||
|
||||
|
|
@ -296,16 +295,15 @@ class Command(BaseCommand):
|
|||
'''send survey link 2 weeks after mailadresss, mailinglist or businesscards are granted'''
|
||||
lastdate = date.today() - timedelta(days=14)
|
||||
|
||||
typefield = ('MAIL','VIS','LIST')
|
||||
count = 0
|
||||
for c in ('Email', 'BusinessCard', 'List'):
|
||||
# get class via string
|
||||
supported = getattr(sys.modules[__name__], c).objects.filter(granted=True)\
|
||||
models = Email, BusinessCard, List
|
||||
types = 'MAIL', 'VIS', 'LIST'
|
||||
|
||||
for model, typ in zip(models, types):
|
||||
supported = model.objects.filter(granted=True)\
|
||||
.filter(granted_date__lt = lastdate)\
|
||||
.exclude(survey_mail_send=True)\
|
||||
.exclude(mail_state = 'END')
|
||||
self.surveymails_to_object(supported, type=typefield[count])
|
||||
count += 1
|
||||
self.surveymails_to_object(supported, type=typ)
|
||||
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
|
|
|||
Loading…
Reference in New Issue