Modified the IndexView to send text email on receiving new order

This commit is contained in:
M.Ravi 2017-06-11 20:06:54 +05:30
parent d7a2335cf4
commit 943fc741bf

View file

@ -280,7 +280,6 @@ class IndexView(CreateView):
return HttpResponseRedirect(reverse('datacenterlight:order')) return HttpResponseRedirect(reverse('datacenterlight:order'))
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,
@ -290,14 +289,13 @@ class IndexView(CreateView):
'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'))