Feature/lilcoin popup See merge request lilschool/site!282remotes/origin/hotfix/gift-cert-fix
commit
26dfd4d7a6
33 changed files with 484 additions and 29 deletions
@ -0,0 +1,18 @@ |
||||
# Generated by Django 2.0.7 on 2019-03-27 20:54 |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0032_auto_20190207_1233'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='userbonus', |
||||
name='notified_at', |
||||
field=models.DateTimeField(blank=True, null=True), |
||||
), |
||||
] |
||||
@ -0,0 +1,22 @@ |
||||
# Generated by Django 2.0.7 on 2019-03-27 20:55 |
||||
|
||||
from django.utils import timezone |
||||
from django.db import migrations |
||||
|
||||
|
||||
def fill_bonuses_notified_at(apps, schema_editor): |
||||
UserBonus = apps.get_model('payment', 'UserBonus') |
||||
for ub in UserBonus.objects.filter(notified_at__isnull=True): |
||||
ub.notified_at = timezone.now() |
||||
ub.save() |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0033_userbonus_notified_at'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RunPython(fill_bonuses_notified_at), |
||||
] |
||||
@ -0,0 +1,18 @@ |
||||
# Generated by Django 2.0.7 on 2019-04-05 18:28 |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0034_auto_20190327_2055'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AlterField( |
||||
model_name='userbonus', |
||||
name='action_name', |
||||
field=models.CharField(blank=True, default='', max_length=20), |
||||
), |
||||
] |
||||
@ -0,0 +1 @@ |
||||
# -*- coding: utf-8 -*- |
||||
@ -0,0 +1,18 @@ |
||||
# Generated by Django 2.0.7 on 2019-04-04 18:07 |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('user', '0030_auto_20190318_1320'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='user', |
||||
name='review_url', |
||||
field=models.URLField(blank=True, default='', verbose_name='Ссылка на видеоотзыв'), |
||||
), |
||||
] |
||||
@ -0,0 +1,19 @@ |
||||
{% load static %} |
||||
<div class="popup bonuses-came js-popup-bonuses-came" data-manual-close="1"> |
||||
<div class="popup__wrap popup__wrap_md js-popup-wrap"> |
||||
<button class="popup__close js-popup-close"> |
||||
<svg class="icon icon-close"> |
||||
<use xlink:href={% static "img/sprite.svg" %}#icon-close></use> |
||||
</svg> |
||||
</button> |
||||
<div class="popup__body bonuses-came__body"> |
||||
<img class="bonuses-came__img" src="{% static 'img/lilcoin48x54.png' %}" style="width: 60px;" /> |
||||
<div class="bonuses-came__title">Вам начислено</div> |
||||
<div class="bonuses-came__bonuses"></div> |
||||
<div>лиликов</div> |
||||
<div class="bonuses-came__text">Приглашайте друзей в Lil School и получайте {{ config.REFERRER_BONUS }}% от суммы их первой покупки. |
||||
Накапливайте монеты и тратьте их на оплату школы и курсов.</div> |
||||
<a href="{% url 'user-bonuses' %}" class="bonuses-came__link">Узнать больше про Лилики</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,97 @@ |
||||
# -*- coding: utf-8 -*- |
||||
import json |
||||
|
||||
from datetime import timedelta |
||||
|
||||
from django.test import TestCase |
||||
from django.utils.timezone import now |
||||
from django.shortcuts import reverse |
||||
from factory.faker import Faker |
||||
|
||||
from project.tests.factories import UserFactory, CourseFactory |
||||
from apps.payment.models import CoursePayment, SchoolPayment, UserBonus, Payment |
||||
from apps.user.models import User |
||||
|
||||
|
||||
class AutoAddingUserBonusTestCase(TestCase): |
||||
|
||||
def test_adding_user_bonuses_after_paid_more_one(self): |
||||
user = UserFactory.create(role=User.USER_ROLE, first_name='', last_name='', phone='') |
||||
course = CourseFactory.create(price=1000) |
||||
course2 = CourseFactory.create(price=1000) |
||||
self.assertEqual(user.bonus, 0, 'При создании есть бонусы') |
||||
|
||||
cp = CoursePayment.objects.create(user=user, course=course, access_expire=now() + timedelta(100)) |
||||
cp.status = Payment.PW_PAID_STATUSES[0] |
||||
cp.save() |
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, 0, 'Есть бонусы после покупки 1 курса') |
||||
|
||||
cp2 = CoursePayment.objects.create(user=user, course=course2, access_expire=now() + timedelta(100)) |
||||
cp2.status = Payment.PW_PAID_STATUSES[0] |
||||
cp2.save() |
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, UserBonus.AMOUNT_PAID_ONE_MORE, 'Неверное кол-во бонусов после покупки 2 курсов') |
||||
|
||||
cp.delete() |
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, UserBonus.AMOUNT_PAID_ONE_MORE, 'Изменились бонусы после удаления оплаты 1 курса') |
||||
|
||||
user.bonuses.all().delete() |
||||
sp = SchoolPayment.objects.create(user=user, weekdays=[1, 2, 3], add_days=False, date_start=now().date(), |
||||
date_end=(now() + timedelta(30)).date(), amount=1000, status=Payment.PW_PAID_STATUSES[0]) |
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, UserBonus.AMOUNT_PAID_ONE_MORE, 'Неверное кол-во бонусов после покупки курса и школы') |
||||
|
||||
user.bonuses.all().delete() |
||||
cp2.delete() |
||||
sp2 = SchoolPayment.objects.create(user=user, weekdays=[1, 2, 3], add_days=False, date_start=(now() + timedelta(31)).date(), |
||||
date_end=(now() + timedelta(60)).date(), amount=1000, status=Payment.PW_PAID_STATUSES[0]) |
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, UserBonus.AMOUNT_PAID_ONE_MORE, 'Неверное кол-во бонусов после покупки 2 месяцев школы') |
||||
|
||||
User.objects.all().delete() |
||||
CoursePayment.objects.all().delete() |
||||
SchoolPayment.objects.all().delete() |
||||
UserBonus.objects.all().delete() |
||||
|
||||
def test_adding_user_bonuses_after_fill_profile(self): |
||||
user = UserFactory.create(role=User.USER_ROLE, first_name='', last_name='', phone='') |
||||
self.assertEqual(user.bonus, 0, 'При создании есть бонусы') |
||||
self.client.force_login(user) |
||||
data = {k: user.__dict__[k] for k in ['email', 'slug', 'child_first_name', |
||||
'child_last_name', 'child_birthday', 'child_gender', 'city', |
||||
'country', 'birthday', 'gender', 'about', 'instagram', 'facebook', |
||||
'twitter', 'pinterest', 'youtube', 'vkontakte', 'site']} |
||||
|
||||
data.update({ |
||||
'first_name': Faker('first_name').generate({}), |
||||
'last_name': Faker('last_name').generate({}), |
||||
'phone': '+79123456789', |
||||
'old_password': '', |
||||
'new_password1': '', |
||||
'new_password2': '', |
||||
}) |
||||
for k, v in data.items(): |
||||
if v is None: |
||||
data[k] = '' |
||||
self.client.post(reverse('user-edit-profile'), data) |
||||
|
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, UserBonus.AMOUNT_FILL_PROFILE, 'Неверное кол-во бонусов после заполнения профиля') |
||||
|
||||
User.objects.all().delete() |
||||
UserBonus.objects.all().delete() |
||||
|
||||
def test_adding_user_bonuses_after_fill_review_url(self): |
||||
user = UserFactory.create(role=User.USER_ROLE, first_name='', last_name='', phone='') |
||||
self.assertEqual(user.bonus, 0, 'При создании есть бонусы') |
||||
self.client.force_login(user) |
||||
self.client.patch('/api/v1/users/%d/' % user.id, json.dumps({ |
||||
'review_url': 'http://youtube.com/review_url', |
||||
}), 'application/json') |
||||
del user.__dict__['bonus'] |
||||
self.assertEqual(user.bonus, UserBonus.AMOUNT_HAVE_REVIEW, 'Неверное кол-во бонусов после заполнения ссылки на отзыв') |
||||
|
||||
User.objects.all().delete() |
||||
UserBonus.objects.all().delete() |
||||
Binary file not shown.
|
After Width: | Height: | Size: 578 B |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue