parent
404d6da093
commit
fdeed92ab6
5 changed files with 112 additions and 108 deletions
@ -1,79 +1,81 @@ |
|||||||
# from django.core.mail import EmailMessage |
from django.core.mail import EmailMessage |
||||||
# from django.db.models.signals import pre_save, post_save |
from django.db.models.signals import pre_save, post_save |
||||||
# from django.dispatch import receiver |
from django.dispatch import receiver |
||||||
# from yandex_money.models import Payment |
from yandex_money.models import Payment |
||||||
# |
from django.conf import settings |
||||||
# from finance.models import Invoice |
|
||||||
# from access.models.other import Progress |
from finance.models import Invoice |
||||||
# from course_service.maps.api import OutApiRoute |
from courses.models import Course |
||||||
# |
from progress.models import Progress |
||||||
# api = OutApiRoute |
|
||||||
# |
|
||||||
# |
@receiver(pre_save, sender=Invoice) |
||||||
# @receiver(pre_save, sender=Invoice) |
def invoice_signal(instance, **kwargs): |
||||||
# def invoice_signal(instance, **kwargs): |
"""Отправка сообщения после сохранения платежа""" |
||||||
# """Отправка сообщения после сохранения платежа""" |
|
||||||
# if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P': |
course = Course.objects.get(token=instance.bill.course_token) |
||||||
# msg = EmailMessage( |
|
||||||
# 'Вам выставлен новый счёт', |
if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P': |
||||||
# '''Вам выставлен счёт, для оплаты перейдите по ссылке |
msg = EmailMessage( |
||||||
# https://go.skillbox.ru/api/v1/finance/payment/%s/''' % instance.yandex_pay.id, |
'Вам выставлен новый счёт', |
||||||
# 'robo@skillbox.ru', |
'''Вам выставлен счёт, для оплаты перейдите по ссылке |
||||||
# [instance.yandex_pay.cps_email], |
%s/api/v1/finance/payment/%s/''' % (settings.DOMAIN, instance.yandex_pay.id,), |
||||||
# [instance.bill.opener.email], |
'robo@skillbox.ru', |
||||||
# reply_to=[instance.bill.opener.email], |
[instance.yandex_pay.cps_email], |
||||||
# ) |
[instance.bill.opener.email], |
||||||
# msg.send() |
reply_to=[instance.bill.opener.email], |
||||||
# |
) |
||||||
# if instance.status == 'F': |
msg.send() |
||||||
# if instance.is_open: |
|
||||||
# Progress.objects.get_or_create( |
if instance.status == 'F': |
||||||
# route=instance.bill.route, |
if instance.is_open: |
||||||
# user=instance.bill.user, |
Progress.objects.get_or_create( |
||||||
# ) |
course_token=instance.bill.course_token, |
||||||
# msg = EmailMessage( |
user=instance.bill.user, |
||||||
# 'Ваш платёж прошёл успешно', |
) |
||||||
# '''Вам открыт доступ к курсу "%s", вы можете перейти по ссылке и |
msg = EmailMessage( |
||||||
# ознакомиться с материалами https://go.skillbox.ru/course/%s''' |
'Ваш платёж прошёл успешно', |
||||||
# % (api.get_route(instance.bill.route).name, api.get_route(instance.bill.route).course.slug), |
'''Вам открыт доступ к курсу "%s", вы можете перейти по ссылке и |
||||||
# 'robo@skillbox.ru', |
ознакомиться с материалами %s/course/%s''' |
||||||
# [instance.bill.user.email], |
% (course.title, settings.DOMAIN, course.slug), |
||||||
# cc=[instance.bill.opener.email], |
'robo@skillbox.ru', |
||||||
# reply_to=[instance.bill.opener.email], |
[instance.bill.user.email], |
||||||
# ) |
cc=[instance.bill.opener.email], |
||||||
# else: |
reply_to=[instance.bill.opener.email], |
||||||
# msg = EmailMessage( |
) |
||||||
# 'Ваш платёж прошёл успешно', |
else: |
||||||
# '''Курс "%s" был забронирован''' % instance.bill.course.title, |
msg = EmailMessage( |
||||||
# 'robo@skillbox.ru', |
'Ваш платёж прошёл успешно', |
||||||
# [instance.yandex_pay.cps_email], |
'''Курс "%s" был забронирован''' % instance.bill.course.title, |
||||||
# cc=[instance.bill.opener.email], |
'robo@skillbox.ru', |
||||||
# reply_to=[instance.bill.opener.email], |
[instance.yandex_pay.cps_email], |
||||||
# ) |
cc=[instance.bill.opener.email], |
||||||
# msg.send() |
reply_to=[instance.bill.opener.email], |
||||||
# |
) |
||||||
# if instance.status == 'C': |
msg.send() |
||||||
# msg = EmailMessage( |
|
||||||
# 'Ошибка платежа!' |
if instance.status == 'C': |
||||||
# """Внимание не прошёл платёж пользавателю %s, |
msg = EmailMessage( |
||||||
# по курсу "%s" ID платежа: %s. Если не получается |
'Ошибка платежа!' |
||||||
# решить проблему самостоятельно, ответьте на это письмо, |
"""Внимание не прошёл платёж пользавателю %s, |
||||||
# постарайтесь подробно описать последовательность действий, |
по курсу "%s" ID платежа: %s. Если не получается |
||||||
# которая привела к ошибке""" |
решить проблему самостоятельно, ответьте на это письмо, |
||||||
# % (instance.bill.user.get_full_name(), api.get_route(instance.bill.route).course.title, instance.id), |
постарайтесь подробно описать последовательность действий, |
||||||
# instance.bill.opener.email, |
которая привела к ошибке""" |
||||||
# reply_to=["it@skillbox.ru"] |
% (instance.bill.user.get_full_name(), course.title, instance.id), |
||||||
# ) |
instance.bill.opener.email, |
||||||
# msg.send() |
reply_to=["it@skillbox.ru"] |
||||||
# |
) |
||||||
# |
msg.send() |
||||||
# @receiver(post_save, sender=Payment) |
|
||||||
# def access_pay(instance, **kwargs): |
|
||||||
# if instance.status == 'success': |
@receiver(post_save, sender=Payment) |
||||||
# instance.invoice.status = "F" |
def access_pay(instance, **kwargs): |
||||||
# instance.invoice.real_price = instance.shop_amount |
if instance.status == 'success': |
||||||
# instance.invoice.save() |
instance.invoice.status = "F" |
||||||
# |
instance.invoice.real_price = instance.shop_amount |
||||||
# if instance.status == 'fail': |
instance.invoice.save() |
||||||
# instance.invoice.status = "C" |
|
||||||
# instance.invoice.save() |
if instance.status == 'fail': |
||||||
|
instance.invoice.status = "C" |
||||||
|
instance.invoice.save() |
||||||
|
|||||||
Loading…
Reference in new issue