added mail to IF
This commit is contained in:
parent
8ad0f91c85
commit
dfc449f0de
2 changed files with 26 additions and 11 deletions
3
input/templates/input/if_mail.txt
Normal file
3
input/templates/input/if_mail.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Hallo IF,
|
||||||
|
|
||||||
|
es gab einen neuen Antrag von {{data.realname}}
|
|
@ -2,7 +2,7 @@ from django.shortcuts import render
|
||||||
from django.forms import modelformset_factory
|
from django.forms import modelformset_factory
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from formtools.wizard.views import CookieWizardView
|
from formtools.wizard.views import CookieWizardView
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail, BadHeaderError
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
|
@ -89,9 +89,10 @@ class ExternView(CookieWizardView):
|
||||||
form.save()
|
form.save()
|
||||||
|
|
||||||
# we need to send the following mails here:
|
# we need to send the following mails here:
|
||||||
|
context = { 'data': data }
|
||||||
|
try:
|
||||||
# - mail with entered data to the Volunteer
|
# - mail with entered data to the Volunteer
|
||||||
mail_template = get_template('input/ifg_volunteer_mail.txt')
|
mail_template = get_template('input/ifg_volunteer_mail.txt')
|
||||||
context = { 'data': data }
|
|
||||||
send_mail(
|
send_mail(
|
||||||
'form filled',
|
'form filled',
|
||||||
mail_template.render(context),
|
mail_template.render(context),
|
||||||
|
@ -100,6 +101,17 @@ class ExternView(CookieWizardView):
|
||||||
fail_silently=False,
|
fail_silently=False,
|
||||||
)
|
)
|
||||||
# - mail to IF with link to accept/decline
|
# - mail to IF with link to accept/decline
|
||||||
|
mail_template = get_template('input/if_mail.txt')
|
||||||
|
send_mail(
|
||||||
|
'form filled',
|
||||||
|
mail_template.render(context),
|
||||||
|
settings.IF_EMAIL,
|
||||||
|
[settings.IF_EMAIL],
|
||||||
|
fail_silently=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
except BadHeaderError:
|
||||||
|
return HttpResponse('Invalid header found.')
|
||||||
|
|
||||||
return done(self.request)
|
return done(self.request)
|
||||||
# return render(self.request, 'saved', {
|
# return render(self.request, 'saved', {
|
||||||
|
|
Loading…
Reference in a new issue