|
|
@ -35,14 +35,22 @@ class Command(BaseCommand): |
|
|
|
'name': name, |
|
|
|
'pid': pid, |
|
|
|
'SURVEYPREFIX': SURVEYPREFIX, } |
|
|
|
mail_template = get_template('input/survey_mail.txt') |
|
|
|
txt_mail_template = get_template('input/survey_mail.txt') |
|
|
|
html_mail_template = get_template('input/survey_mail.html') |
|
|
|
try: |
|
|
|
survey_mail = EmailMessage('Dein Feedback zur Förderung durch Wikimedia Deutschland', |
|
|
|
mail_template.render(context), |
|
|
|
IF_EMAIL, |
|
|
|
[email], |
|
|
|
bcc=[SURVEY_EMAIL]) |
|
|
|
survey_mail.send(fail_silently=False) |
|
|
|
subject, from_email, to = 'Dein Feedback zur Förderung durch Wikimedia Deutschland', IF_EMAIL, email |
|
|
|
text_content = txt_mail_template.render(context) |
|
|
|
html_content = html_mail_template.render(context) |
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [to], bcc=[SURVEY_EMAIL]) |
|
|
|
msg.attach_alternative(html_content, "text/html") |
|
|
|
msg.send() |
|
|
|
|
|
|
|
#survey_mail = EmailMessage('Dein Feedback zur Förderung durch Wikimedia Deutschland', |
|
|
|
# mail_template.render(context), |
|
|
|
# IF_EMAIL, |
|
|
|
# [email], |
|
|
|
# bcc=[SURVEY_EMAIL]) |
|
|
|
#survey_mail.send(fail_silently=False) |
|
|
|
except BadHeaderError: |
|
|
|
return HttpResponse('Invalid header found.') |
|
|
|
|
|
|
@ -52,20 +60,28 @@ class Command(BaseCommand): |
|
|
|
''' end of project reached ''' |
|
|
|
# get all projects which ended |
|
|
|
|
|
|
|
print(Project.objects.filter(end__lt = date.today())) |
|
|
|
old = Project.objects.filter(end__lt = date.today())\ |
|
|
|
.exclude(end_mail_send = True) |
|
|
|
|
|
|
|
mail_template = get_template('input/if_end_of_project.txt') |
|
|
|
txt_mail_template = get_template('input/if_end_of_project.txt') |
|
|
|
html_mail_template = get_template('input/if_end_of_project.html') |
|
|
|
|
|
|
|
for project in old: |
|
|
|
context = {'project': project} |
|
|
|
context['URLPREFIX'] = settings.URLPREFIX |
|
|
|
try: |
|
|
|
send_mail('Projektende erreicht', |
|
|
|
mail_template.render(context), |
|
|
|
IF_EMAIL, |
|
|
|
['luca@cannabinieri.de'], |
|
|
|
fail_silently=False) |
|
|
|
subject, from_email, to = 'Projektende erreicht', IF_EMAIL, IF_EMAIL |
|
|
|
text_content = txt_mail_template.render(context) |
|
|
|
html_content = html_mail_template.render(context) |
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) |
|
|
|
msg.attach_alternative(html_content, "text/html") |
|
|
|
msg.send() |
|
|
|
|
|
|
|
#send_mail('Projektende erreicht', |
|
|
|
# mail_template.render(context), |
|
|
|
# IF_EMAIL, |
|
|
|
# [IF_EMAIL], |
|
|
|
# fail_silently=False) |
|
|
|
project.end_mail_send = True |
|
|
|
project.save() |
|
|
|
except BadHeaderError: |
|
|
@ -80,24 +96,42 @@ class Command(BaseCommand): |
|
|
|
approved_end = Project.objects.filter(status = 'END')\ |
|
|
|
.exclude(end_mail_send = False) |
|
|
|
print(approved_end) |
|
|
|
mail_template = get_template('input/if_end_of_project_approved.txt') |
|
|
|
informMail_template = get_template('input/if_end_of_project_orginformed.txt') |
|
|
|
txt_mail_template = get_template('input/if_end_of_project_approved.txt') |
|
|
|
html_mail_template = get_template('input/if_end_of_project_approved.html') |
|
|
|
|
|
|
|
txt_informMail_template = get_template('input/if_end_of_project_orginformed.txt') |
|
|
|
html_informMail_template = get_template('input/if_end_of_project_orginformed.html') |
|
|
|
# send the mail to project.email, which would be the mail of the volunteer filling out the form |
|
|
|
|
|
|
|
for project in approved_end: |
|
|
|
context = {'project': project} |
|
|
|
context['URLPREFIX'] = settings.URLPREFIX |
|
|
|
try: |
|
|
|
send_mail('Projektende erreicht', |
|
|
|
mail_template.render(context), |
|
|
|
IF_EMAIL, |
|
|
|
[project.email], |
|
|
|
fail_silently=False) |
|
|
|
send_mail('Projektorganisator*in wurde informiert', |
|
|
|
informMail_template.render(context), |
|
|
|
IF_EMAIL, |
|
|
|
[IF_EMAIL], |
|
|
|
fail_silently=False) |
|
|
|
subject, from_email, to = 'Projektende erreicht', IF_EMAIL, project.email |
|
|
|
text_content = txt_mail_template.render(context) |
|
|
|
html_content = html_mail_template.render(context) |
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) |
|
|
|
msg.attach_alternative(html_content, "text/html") |
|
|
|
msg.send() |
|
|
|
|
|
|
|
inform_subject, inform_from_email, inform_to = Projektorganisator*in wurde informiert', IF_EMAIL, IF_EMAIL |
|
|
|
inform_text_content = txt_informMail_template.render(context) |
|
|
|
inform_html_content = html_informMail_template.render(context) |
|
|
|
inform_msg = EmailMultiAlternatives(inform_subject, inform_text_content, inform_from_email, [inform_to]) |
|
|
|
inform_msg.attach_alternative(html_content, "text/html") |
|
|
|
inform_msg.send() |
|
|
|
|
|
|
|
|
|
|
|
#send_mail('Projektende erreicht', |
|
|
|
# mail_template.render(context), |
|
|
|
# IF_EMAIL, |
|
|
|
# [project.email], |
|
|
|
# fail_silently=False) |
|
|
|
#send_mail('Projektorganisator*in wurde informiert', |
|
|
|
# informMail_template.render(context), |
|
|
|
# IF_EMAIL, |
|
|
|
# [IF_EMAIL], |
|
|
|
# fail_silently=False) |
|
|
|
|
|
|
|
project.end_mail_send = True |
|
|
|
project.save() |
|
|
|