Merge branch 'master' of gitlab.com:lilcity/backend into hotfix/LIL-706

remotes/origin/editis_13-01-19
gzbender 7 years ago
commit a789a0e396
  1. 21
      api/v1/serializers/payment.py
  2. 38
      apps/payment/management/commands/send_transactions_to_roistat.py
  3. 7
      apps/payment/templates/payment/gift_certificate_item.html
  4. 4
      apps/payment/views.py
  5. 2
      apps/user/templates/user/bonus-history.html
  6. 21
      docker/conf/nginx/conf.d/default.conf
  7. 14
      docker/conf/supervisor/flower.conf
  8. 2
      docker/docker-compose-review.yml
  9. 2
      requirements.txt

@ -3,7 +3,7 @@ from rest_framework import serializers
from apps.payment.models import (
AuthorBalance, Payment,
CoursePayment, SchoolPayment,
)
GiftCertificatePayment)
from .user import UserSerializer
from .course import CourseSerializer
@ -114,6 +114,8 @@ class PaymentSerializer(serializers.ModelSerializer):
return CoursePaymentSerializer(instance, context=self.context).to_representation(instance)
elif isinstance(instance, SchoolPayment):
return SchoolPaymentSerializer(instance, context=self.context).to_representation(instance)
elif isinstance(instance, GiftCertificatePayment):
return GiftCertificatePaymentSerializer(instance, context=self.context).to_representation(instance)
class CoursePaymentCreateSerializer(serializers.ModelSerializer):
@ -181,3 +183,20 @@ class SchoolPaymentSerializer(serializers.ModelSerializer):
'created_at',
'update_at',
)
class GiftCertificatePaymentSerializer(serializers.ModelSerializer):
user = UserSerializer()
class Meta:
model = GiftCertificatePayment
fields = BASE_PAYMENT_FIELDS + (
'gift_certificate',
)
read_only_fields = (
'id',
'user',
'course',
'created_at',
'update_at',
)

@ -0,0 +1,38 @@
from django.core.management.base import BaseCommand, CommandError
from django.utils.timezone import now
from paymentwall.pingback import Pingback
from apps.payment.tasks import transaction_to_roistat
from apps.payment.models import Payment
import logging
logger = logging.getLogger(__name__)
class Command(BaseCommand):
help = 'Send '
def add_arguments(self, parser):
parser.add_argument(
'start_id', type=int,
help='Start payment id',
)
def handle(self, *args, **options):
start_id = options.get('start_id')
print('start_id=' + str(start_id))
payments = Payment.objects.filter(id__gte=start_id, status__in=Payment.PW_PAID_STATUSES)
for payment in payments:
print('TRANSACTION: ' + str(payment.id))
transaction_to_roistat.delay(
payment.user.id,
payment.id,
f'School payment',
payment.amount,
payment.created_at.strftime('%Y-%m-%d %H:%M:%S'),
0,
f'school',
payment.roistat_visit,
)

@ -8,9 +8,8 @@
</div>
<div class="gift-certificates__details">
<span class="gift-certificates__title theme {{ theme_color }}">
{% if user_gift_certificate and not user_gift_certificate.bonuses_sent %}
<a href="{% url 'gift-certificate-get' user_gift_certificate.code %}">подарочный сертификат</a>
{% else %}подарочный сертификат{% endif %}</span>
Подарочный сертификат
</span>
<div class="gift-certificates__price">{{ gift_certificate.price|floatformat:"-2" }}₽</div>
</div>
{% if user_gift_certificate %}
@ -22,7 +21,7 @@
{% else %}
<div class="gift-certificates__status">
<img class="icon" style="margin-top: -1px; height: auto;" src="{% static 'img/clock.png' %}" />
Ожидает получения
Ожидает получения | Код <span style="text-transform: none">{{ user_gift_certificate.code }}</span>
</div>
{% endif %}
{% else %}

@ -211,8 +211,8 @@ class PaymentwallCallbackView(View):
pingback = Pingback(payment_raw_data, self.get_request_ip())
if pingback.validate():
spltted = pingback.get_product().get_id().split('_')
product_type_name, payment_id = '_'.join(spltted[:-1]), spltted[-1]
splitted = pingback.get_product().get_id().split('_')
product_type_name, payment_id = '_'.join(splitted[:-1]), splitted[-1]
if product_type_name == 'course':
product_payment_class = CoursePayment

@ -49,6 +49,8 @@
{% with payment=bonus.payment %}
{% if payment.course %}
<div class="transactions__cell transactions__product">Курс. {{ payment.course.title }}</div>
{% elif payment.giftcertificate %}
<div class="transactions__cell transactions__product">Подарочный сертификат</div>
{% else %}
<div class="transactions__cell transactions__product">
{% if request.user_agent.is_mobile %}

@ -1,3 +1,24 @@
server {
listen 80;
server_name ~^flower.+;
root /dev/null;
access_log off;
error_log /dev/stdout;
log_not_found off;
location / {
proxy_pass http://127.0.0.1:5555;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80 default_server;

@ -0,0 +1,14 @@
[program:flower]
command=/usr/local/bin/flower -A project
directory=/app/
environment=HOME="/var/www"
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stopsignal=KILL
stopasgroup=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0

@ -48,7 +48,7 @@ services:
- internal
- review
labels:
- traefik.frontend.rule=Host:${REVIEW_HOST}
- traefik.frontend.rule=Host:${REVIEW_HOST},flower-${REVIEW_HOST}
- traefik.docker.network=review
networks:

@ -1,5 +1,6 @@
# Python-3.6
arrow==0.12.1
redis==2.10.6
celery[redis]==4.2.0
Django==2.0.7
django-active-link==0.1.5
@ -34,3 +35,4 @@ pusher==2.0.1
short_url
sendgrid
drf_dynamic_fields
flower==0.9.2

Loading…
Cancel
Save