commit
215d70d518
16 changed files with 339 additions and 135 deletions
@ -0,0 +1,22 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.11.6 on 2018-02-19 13:23 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
import django.contrib.postgres.fields |
||||||
|
from django.db import migrations, models |
||||||
|
import lms.tools |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('access', '0002_init_group'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AlterField( |
||||||
|
model_name='useractivity', |
||||||
|
name='ip_list', |
||||||
|
field=django.contrib.postgres.fields.ArrayField(base_field=models.GenericIPAddressField(editable=False, verbose_name='Ip адресс'), default=lms.tools.get_empty_list, size=None), |
||||||
|
), |
||||||
|
] |
||||||
@ -1,81 +1,95 @@ |
|||||||
# from django.core.mail import EmailMessage |
from django.contrib.auth import get_user_model |
||||||
# from django.db.models.signals import pre_save, post_save |
from django.core.mail import EmailMessage |
||||||
# from django.dispatch import receiver |
from django.db.models.signals import pre_save, post_save |
||||||
# from yandex_money.models import Payment |
from django.dispatch import receiver |
||||||
# from django.conf import settings |
from yandex_money.models import Payment |
||||||
# |
from django.conf import settings |
||||||
# from finance.models import Invoice |
|
||||||
# from courses.models import Course |
from finance.models import Invoice |
||||||
# from progress.models import Progress |
from courses.models import Course |
||||||
# |
from progress.models import Progress, ProgressLesson |
||||||
# |
|
||||||
# @receiver(pre_save, sender=Invoice) |
|
||||||
# def invoice_signal(instance, **kwargs): |
@receiver(pre_save, sender=Invoice) |
||||||
# """Отправка сообщения после сохранения платежа""" |
def invoice_signal(instance, **kwargs): |
||||||
# |
"""Отправка сообщения после сохранения платежа""" |
||||||
# course = Course.objects.get(token=instance.bill.course_token) |
|
||||||
# |
course = Course.objects.get(token=instance.bill.course_token) |
||||||
# if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P': |
|
||||||
# msg = EmailMessage( |
if instance.yandex_pay and instance.method == 'Y' and instance.status == 'P': |
||||||
# 'Вам выставлен новый счёт', |
msg = EmailMessage( |
||||||
# '''Вам выставлен счёт, для оплаты перейдите по ссылке |
'Вам выставлен новый счёт', |
||||||
# %s/api/v1/finance/payment/%s/''' % (settings.DOMAIN, instance.yandex_pay.id,), |
'''Вам выставлен счёт, для оплаты перейдите по ссылке |
||||||
# 'robo@skillbox.ru', |
%s/api/v1/finance/payment/%s/''' % (settings.DOMAIN, instance.yandex_pay.id,), |
||||||
# [instance.yandex_pay.cps_email], |
'robo@skillbox.ru', |
||||||
# [instance.bill.opener.email], |
[instance.yandex_pay.cps_email], |
||||||
# reply_to=[instance.bill.opener.email], |
[instance.bill.opener.email], |
||||||
# ) |
reply_to=[instance.bill.opener.email], |
||||||
# msg.send() |
) |
||||||
# |
msg.send() |
||||||
# if instance.status == 'F': |
|
||||||
# if instance.is_open: |
if instance.status == 'F': |
||||||
# Progress.objects.get_or_create( |
if instance.is_open: |
||||||
# course_token=instance.bill.course_token, |
try: |
||||||
# user=instance.bill.user, |
Progress.objects.get( |
||||||
# ) |
course_token=instance.bill.course_token, |
||||||
# msg = EmailMessage( |
user=instance.bill.user, |
||||||
# 'Ваш платёж прошёл успешно', |
) |
||||||
# '''Вам открыт доступ к курсу "%s", вы можете перейти по ссылке и |
except Progress.DoesNotExist: |
||||||
# ознакомиться с материалами %s/course/%s''' |
p=Progress.objects.create( |
||||||
# % (course.title, settings.DOMAIN, course.slug), |
course_token=instance.bill.course_token, |
||||||
# 'robo@skillbox.ru', |
user=instance.bill.user, |
||||||
# [instance.bill.user.email], |
teacher=get_user_model().objects.get(out_key=course.get_teacher()) |
||||||
# cc=[instance.bill.opener.email], |
) |
||||||
# reply_to=[instance.bill.opener.email], |
ProgressLesson.objects.create( |
||||||
# ) |
progress=p, |
||||||
# else: |
lesson_token=course.get_first_lesson().token, |
||||||
# msg = EmailMessage( |
checker=p.user, |
||||||
# 'Ваш платёж прошёл успешно', |
) |
||||||
# '''Курс "%s" был забронирован''' % instance.bill.course.title, |
|
||||||
# 'robo@skillbox.ru', |
msg = EmailMessage( |
||||||
# [instance.yandex_pay.cps_email], |
'Ваш платёж прошёл успешно', |
||||||
# cc=[instance.bill.opener.email], |
'''Вам открыт доступ к курсу "%s", вы можете перейти по ссылке и |
||||||
# reply_to=[instance.bill.opener.email], |
ознакомиться с материалами %s/course/%s''' |
||||||
# ) |
% (course.title, settings.DOMAIN, course.slug), |
||||||
# msg.send() |
'robo@skillbox.ru', |
||||||
# |
[instance.bill.user.email], |
||||||
# if instance.status == 'C': |
cc=[instance.bill.opener.email], |
||||||
# msg = EmailMessage( |
reply_to=[instance.bill.opener.email], |
||||||
# 'Ошибка платежа!' |
) |
||||||
# """Внимание не прошёл платёж пользавателю %s, |
else: |
||||||
# по курсу "%s" ID платежа: %s. Если не получается |
msg = EmailMessage( |
||||||
# решить проблему самостоятельно, ответьте на это письмо, |
'Ваш платёж прошёл успешно', |
||||||
# постарайтесь подробно описать последовательность действий, |
'''Курс "%s" был забронирован''' % course.title, |
||||||
# которая привела к ошибке""" |
'robo@skillbox.ru', |
||||||
# % (instance.bill.user.get_full_name(), course.title, instance.id), |
[instance.bill.user.email], |
||||||
# instance.bill.opener.email, |
cc=[instance.bill.opener.email], |
||||||
# reply_to=["it@skillbox.ru"] |
reply_to=[instance.bill.opener.email], |
||||||
# ) |
) |
||||||
# msg.send() |
msg.send() |
||||||
# |
|
||||||
# |
if instance.status == 'C': |
||||||
# @receiver(post_save, sender=Payment) |
msg = EmailMessage( |
||||||
# def access_pay(instance, **kwargs): |
'Ошибка платежа!' |
||||||
# if instance.status == 'success': |
"""Внимание не прошёл платёж пользавателю %s, |
||||||
# instance.invoice.status = "F" |
по курсу "%s" ID платежа: %s. Если не получается |
||||||
# instance.invoice.real_price = instance.shop_amount |
решить проблему самостоятельно, ответьте на это письмо, |
||||||
# instance.invoice.save() |
постарайтесь подробно описать последовательность действий, |
||||||
# |
которая привела к ошибке""" |
||||||
# if instance.status == 'fail': |
% (instance.bill.user.get_full_name(), course.title, instance.id), |
||||||
# instance.invoice.status = "C" |
instance.bill.opener.email, |
||||||
# instance.invoice.save() |
reply_to=["it@skillbox.ru"] |
||||||
|
) |
||||||
|
msg.send() |
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=Payment) |
||||||
|
def access_pay(instance, **kwargs): |
||||||
|
if instance.status == 'success': |
||||||
|
instance.invoice.status = "F" |
||||||
|
instance.invoice.real_price = instance.shop_amount |
||||||
|
instance.invoice.save() |
||||||
|
|
||||||
|
if instance.status == 'fail': |
||||||
|
instance.invoice.status = "C" |
||||||
|
instance.invoice.save() |
||||||
|
|||||||
@ -0,0 +1,22 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
# Generated by Django 1.11.6 on 2018-02-19 13:17 |
||||||
|
from __future__ import unicode_literals |
||||||
|
|
||||||
|
import django.contrib.postgres.fields |
||||||
|
from django.db import migrations, models |
||||||
|
import progress.models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('progress', '0004_progress_is_finish'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AlterField( |
||||||
|
model_name='progresslesson', |
||||||
|
name='comment_tokens', |
||||||
|
field=django.contrib.postgres.fields.ArrayField(base_field=models.UUIDField(editable=False, verbose_name='Токен комента'), default=progress.models.get_empty_list, size=None), |
||||||
|
), |
||||||
|
] |
||||||
Loading…
Reference in new issue