Merge branch 'roistat' into 'master'

Roistat

See merge request lilcity/backend!62
remotes/origin/hasaccess^2
cfwme 8 years ago
commit 34070d0cc9
  1. 3
      apps/payment/admin.py
  2. 18
      apps/payment/migrations/0019_payment_roistat_visit.py
  3. 1
      apps/payment/models.py
  4. 3
      apps/payment/tasks.py
  5. 6
      apps/payment/views.py
  6. 11
      requirements.txt

@ -28,10 +28,11 @@ class PaymentChildAdmin(PolymorphicChildModelAdmin):
'user',
'amount',
'status',
'roistat_visit',
'created_at',
)
base_fieldsets = (
(None, {'fields': ('user', 'amount', 'status', 'data',)}),
(None, {'fields': ('user', 'amount', 'status', 'data', 'roistat_visit',)}),
)
readonly_fields = ('amount', 'data',)

@ -0,0 +1,18 @@
# Generated by Django 2.0.7 on 2018-07-06 07:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('payment', '0018_auto_20180512_1202'),
]
operations = [
migrations.AddField(
model_name='payment',
name='roistat_visit',
field=models.PositiveIntegerField(editable=False, null=True, verbose_name='Номер визита Roistat'),
),
]

@ -97,6 +97,7 @@ class Payment(PolymorphicModel):
amount = models.DecimalField('Итого', max_digits=8, decimal_places=2, default=0, editable=False)
status = models.PositiveSmallIntegerField('Статус платежа', choices=PW_STATUS_CHOICES, null=True)
data = JSONField('Данные платежа от провайдера', default={}, editable=False)
roistat_visit = models.PositiveIntegerField('Номер визита Roistat', null=True, editable=False)
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)

@ -38,12 +38,13 @@ def product_payment_to_mixpanel(user_id, event_name, time, properties):
@app.task
def transaction_to_roistat(user_id, payment_id, event_name, amount, time, status, product_type):
def transaction_to_roistat(user_id, payment_id, event_name, amount, time, status, product_type, roistat_visit):
body = [{
'id': str(payment_id),
'name': event_name,
'date_create': time,
'status': str(status),
'roistat': str(roistat_visit) if roistat_visit else None,
'price': str(amount),
'client_id': str(user_id),
'fields': {

@ -58,12 +58,14 @@ class CourseBuyView(TemplateView):
host = urlsplit(self.request.META.get('HTTP_REFERER'))
host = str(host[0]) + '://' + str(host[1])
course = Course.objects.get(id=pk)
roistat_visit = request.COOKIES.get('roistat_visit', None)
if request.user == course.author:
messages.error(request, 'Вы не можете приобрести свой курс.')
return redirect(reverse_lazy('course', args=[course.id]))
course_payment = CoursePayment.objects.create(
user=request.user,
course=course,
roistat_visit=roistat_visit,
)
product = Product(
f'course_{course_payment.id}',
@ -96,6 +98,7 @@ class SchoolBuyView(TemplateView):
host = str(host[0]) + '://' + str(host[1])
weekdays = set(request.GET.getlist('weekdays', []))
add_days = 'add_days' in request.GET
roistat_visit = request.COOKIES.get('roistat_visit', None)
if not weekdays:
messages.error(request, 'Выберите несколько дней недели.')
return redirect('school:summer-school')
@ -117,6 +120,7 @@ class SchoolBuyView(TemplateView):
date_start=now().date(),
date_end=_school_payment.date_end,
add_days=True,
roistat_visit=roistat_visit,
)
if school_payment.amount <= 0:
messages.error(request, 'Выбранные дни отсутствуют в оставшемся периоде подписки')
@ -125,6 +129,7 @@ class SchoolBuyView(TemplateView):
school_payment = SchoolPayment.objects.create(
user=request.user,
weekdays=weekdays,
roistat_visit=roistat_visit,
)
product = Product(
f'school_{school_payment.id}',
@ -259,6 +264,7 @@ class PaymentwallCallbackView(View):
now().strftime('%Y-%m-%d %H:%M:%S'),
pingback.get_type(),
product_type_name,
payment.roistat_visit,
)
author_balance = getattr(payment, 'author_balance', None)
if author_balance and author_balance.type == AuthorBalance.IN:

@ -1,27 +1,26 @@
# Python-3.6
arrow==0.12.1
celery[redis]==4.2.0
Django==2.0.6
Django==2.0.7
django-active-link==0.1.5
django-anymail[mailgun]==3.0
django-cors-headers==2.3.0
django_compressor==2.2
django-filter==2.0.0.dev1
django-mptt==0.9.0
django-silk==3.0.0
django-phonenumber-field==2.0.0
django-polymorphic-tree==1.5
djangorestframework==3.8.2
drf-yasg[validation]==1.9.0
drf-yasg==1.9.0
facepy==1.0.9
gunicorn==19.8.1
gunicorn==19.9.0
mixpanel==4.3.2
psycopg2-binary==2.7.5
Pillow==5.1.0
Pillow==5.2.0
raven==6.9.0
requests==2.19.1
sorl-thumbnail==12.4.1
twilio==6.14.6
twilio==6.14.7
# paymentwall-python==1.0.7
git+https://github.com/ivlevdenis/paymentwall-python.git
# python-instagram==1.3.2

Loading…
Cancel
Save