Send order emails as plain text
This commit is contained in:
parent
ce33a4b3f2
commit
9f2f0f7db3
1 changed files with 9 additions and 13 deletions
|
@ -4,6 +4,7 @@ from .forms import BetaAccessForm
|
||||||
from .models import BetaAccess, BetaAccessVMType, BetaAccessVM
|
from .models import BetaAccess, BetaAccessVMType, BetaAccessVM
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
|
from django.core.mail import EmailMessage
|
||||||
from utils.mailer import BaseEmail
|
from utils.mailer import BaseEmail
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
@ -118,11 +119,7 @@ class OrderView(TemplateView):
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
|
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order'))
|
return HttpResponseRedirect(reverse('datacenterlight:order'))
|
||||||
|
|
||||||
# We have valid email and name of the customer, hence send an
|
|
||||||
# email to the admin
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host()),
|
|
||||||
'name': name,
|
'name': name,
|
||||||
'email': email,
|
'email': email,
|
||||||
'cores': cores,
|
'cores': cores,
|
||||||
|
@ -132,13 +129,12 @@ class OrderView(TemplateView):
|
||||||
'template': template_data['name'],
|
'template': template_data['name'],
|
||||||
}
|
}
|
||||||
email_data = {
|
email_data = {
|
||||||
'subject': 'New Order Received',
|
'subject': "Data Center Light Order from %s" % context['email'],
|
||||||
'to': 'info@ungleich.ch',
|
'to': 'info@ungleich.ch',
|
||||||
'context': context,
|
'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]),
|
||||||
'template_name': 'new_order_notification',
|
'reply_to': context['email'],
|
||||||
'template_path': 'datacenterlight/emails/'
|
|
||||||
}
|
}
|
||||||
email = BaseEmail(**email_data)
|
email = EmailMessage(**email_data)
|
||||||
email.send()
|
email.send()
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order_success'))
|
return HttpResponseRedirect(reverse('datacenterlight:order_success'))
|
||||||
|
|
Loading…
Reference in a new issue