remotes/origin/diplom_integration
Andrey 8 years ago
parent 8da2c4205d
commit 53cb094345
  1. 45
      finance/views.py

@ -71,6 +71,21 @@ class BillListView(APIView):
invoice.yandex_pay = yandex_pay invoice.yandex_pay = yandex_pay
invoice.save() invoice.save()
msg = EmailMessage(
'Выставден новый счёт.',
'''Менеджер %s выставил счёт пользователю %s на курс "%s".'''
% (
invoice.bill.opener.full_name(),
invoice.bill.user.email,
Course.objects.get(invoice.bill.course_token).title,
),
'robo@skillbox.ru',
[invoice.bill.opener.email],
bcc=['dmitry.dolya@skillbox.ru'],
)
msg.send()
invoices = [j for j in invoices if not j.id == invoice.id] invoices = [j for j in invoices if not j.id == invoice.id]
[i.delete() for i in invoices] [i.delete() for i in invoices]
@ -159,6 +174,17 @@ class YandexPay(APIView):
'shopFailURL': settings.YANDEX_MONEY_FAIL_URL, 'shopFailURL': settings.YANDEX_MONEY_FAIL_URL,
}) })
msg = EmailMessage(
'Пользователь перешёл на страницу оплаты.',
'''Пользователь "%s", переводит %s рублей.'''
% (pay.invoice.bill.user.email, str(pay.invoice.real_price)),
'robo@skillbox.ru',
[pay.invoice.bill.opener.email],
bcc=['dmitry.dolya@skillbox.ru'],
)
msg.send()
return redirect(r.url) return redirect(r.url)
except Payment.DoesNotExist: except Payment.DoesNotExist:
@ -177,8 +203,8 @@ def get_invoices(request):
file_name = file_name + "__to_%s" % date_to if date_to else file_name file_name = file_name + "__to_%s" % date_to if date_to else file_name
invoices = Invoice.objects.filter(method="Y", status="F") invoices = Invoice.objects.filter(method="Y", status="F")
invoices = invoices.filter(date__lt=date_to) if date_to else invoices invoices = invoices.filter(yandex_pay__performed_datetime__lt=date_to) if date_to else invoices
invoices = invoices.filter(date__gte=date_from) if date_from else invoices invoices = invoices.filter(yandex_pay__performed_datetime__gte=date_from) if date_from else invoices
response = HttpResponse(content_type='text/csv') response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="%s.csv"' % file_name response['Content-Disposition'] = 'attachment; filename="%s.csv"' % file_name
@ -189,8 +215,8 @@ def get_invoices(request):
for i in invoices.order_by('-date'): for i in invoices.order_by('-date'):
course_api = CourseParamsApi(i.bill.course_token) course_api = CourseParamsApi(i.bill.course_token)
writer.writerow([ writer.writerow([
i.date.date(), i.yandex_pay.performed_datetime.date(),
i.date.time(), i.yandex_pay.performed_datetime.time(),
i.bill.user.email, i.bill.user.email,
i.bill.user.get_full_name(), i.bill.user.get_full_name(),
course_api.get_slug_and_title()['title'], course_api.get_slug_and_title()['title'],
@ -246,17 +272,6 @@ class YandexCheckView(APIView):
logger_yandex.info(xml_res) logger_yandex.info(xml_res)
msg = EmailMessage(
'Списание средств с карты пользователя.',
'''Пользователь "%s", переволит %s рублей. Номер платежа в яндекс кассе %s'''
% (pay.invoice.bill.user.email, str(pay.invoice.real_price), str(data['invoiceId'])),
'robo@skillbox.ru',
[pay.invoice.bill.opener.email],
bcc=['dmitry.dolya@skillbox.ru'],
)
msg.send()
return HttpResponse(xml_res, content_type='application/xml') return HttpResponse(xml_res, content_type='application/xml')

Loading…
Cancel
Save