|
|
|
|
@ -14,7 +14,8 @@ from rest_framework.views import APIView |
|
|
|
|
from yandex_money.models import Payment |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.core.mail import EmailMultiAlternatives |
|
|
|
|
from django.template.loader import get_template |
|
|
|
|
from django.template.loader import render_to_string |
|
|
|
|
from django.utils.html import strip_tags |
|
|
|
|
|
|
|
|
|
from courses.models import Course |
|
|
|
|
from courses.api import CourseParamsApi |
|
|
|
|
@ -159,9 +160,6 @@ class InvoiceDetailView(APIView): |
|
|
|
|
) |
|
|
|
|
invoice.yandex_pay = yandex_pay |
|
|
|
|
|
|
|
|
|
plaintext = get_template('mail/sales/back_set_bill.txt') |
|
|
|
|
html = get_template('mail/sales/back_set_bill.txt') |
|
|
|
|
|
|
|
|
|
context = { |
|
|
|
|
'user_email': invoice.bill.user.email, |
|
|
|
|
'opener_full_name': invoice.bill.opener.get_full_name(), |
|
|
|
|
@ -172,8 +170,8 @@ class InvoiceDetailView(APIView): |
|
|
|
|
|
|
|
|
|
subject, to = 'Выставлен новый счёт', invoice.bill.opener.email |
|
|
|
|
|
|
|
|
|
text_content = plaintext.render(context) |
|
|
|
|
html_content = html.render(context) |
|
|
|
|
html_content = render_to_string('mail/sales/back_set_bill.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") |
|
|
|
|
@ -411,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') |
|
|
|
|
|