From 8ae4d09a3d22a83500f9697dfaeee94e78b9cff8 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 30 Mar 2018 18:21:20 +0300 Subject: [PATCH] finance email --- finance/signals.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/finance/signals.py b/finance/signals.py index ea0f3cf..da1b573 100644 --- a/finance/signals.py +++ b/finance/signals.py @@ -5,11 +5,27 @@ from django.dispatch import receiver from yandex_money.models import Payment from django.conf import settings -from finance.models import Invoice +from finance.models import Invoice, InvoiceRebilling from courses.models import Course from progress.models import Progress, ProgressLesson +@receiver(pre_save, sender=InvoiceRebilling) +def invoice_signal(instance, **kwargs): + """Отправка сообщения после сохранения рассрочки""" + + if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P': + msg = EmailMessage( + 'Вам выставлен новый счёт', + """%s для оплаты перейдите по ссылке + %s/api/v1/finance/payment/%s/""" % (instance.get_comment(), settings.DOMAIN, instance.yandex_pay.id), + to=[instance.yandex_pay.cps_email], + bcc=[instance.bill.opener.email], + reply_to=[instance.bill.opener.email], + ) + msg.send() + + @receiver(pre_save, sender=Invoice) def invoice_signal(instance, **kwargs): """Отправка сообщения после сохранения платежа"""