diff --git a/finance/views.py b/finance/views.py index 3592119..5ea6815 100644 --- a/finance/views.py +++ b/finance/views.py @@ -409,15 +409,22 @@ class YandexAvisoView(APIView): 'response': xml_res, }) - msg = EmailMessage( - 'Успешная оплата.', - '''Пользователь "%s", перевёл %s рублей. Номер платежа в яндекс кассе %s''' - % (pay.invoice.bill.user.email, str(pay.invoice.price), str(data['invoiceId'])), - 'robo@skillbox.ru', - [pay.invoice.bill.opener.email], - bcc=['dmitry.dolya@skillbox.ru', 'vera.procenko@skillbox.ru'], - ) - + context = { + 'user_email': pay.invoice.bill.user.email, + 'opener_full_name': pay.invoice.bill.opener.get_full_name(), + 'course_title': Course.objects.get(token=pay.invoice.bill.course_token).title, + 'date': str(pay.invoice.date), + 'price': pay.invoice.price, + 'finish_date': pay.performed_datetime, + } + + subject, to = 'Выставлен новый счёт', pay.invoice.bill.opener.email + + html_content = render_to_string('mail/sales/pay_access.html', context) + text_content = strip_tags(html_content) + + msg = EmailMultiAlternatives(subject, text_content, to=[to], bcc=['dmitry.dolya@skillbox.ru']) + msg.attach_alternative(html_content, "text/html") msg.send() return HttpResponse(xml_res, content_type='application/xml') diff --git a/templates/mail/sales/pay_access.html b/templates/mail/sales/pay_access.html new file mode 100644 index 0000000..60cbdd9 --- /dev/null +++ b/templates/mail/sales/pay_access.html @@ -0,0 +1,7 @@ +
Выставлен новый счет
+
Пользователь: {{ user_email }}
+
Продавец: {{ opener_full_name }}
+
Курс: {{ course_title }}
+
Дата продажи: {{ date }}
+
Дата оплаты: {{ finish_date }}
+
Сумма: {{ price }} руб.
\ No newline at end of file