Feature/lil 583 See merge request lilcity/backend!101remotes/origin/hotfix/LIL-691
commit
4db2d1acfd
35 changed files with 617 additions and 147 deletions
@ -0,0 +1,23 @@ |
||||
# Generated by Django 2.0.6 on 2018-07-29 05:03 |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('config', '0008_auto_20180425_1451'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='config', |
||||
name='REFERRAL_DISCOUNT', |
||||
field=models.IntegerField(default=10), |
||||
), |
||||
migrations.AddField( |
||||
model_name='config', |
||||
name='REFERRER_CASHBACK', |
||||
field=models.IntegerField(default=10), |
||||
), |
||||
] |
||||
@ -0,0 +1,23 @@ |
||||
# Generated by Django 2.0.6 on 2018-08-20 08:53 |
||||
|
||||
from django.db import migrations |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('config', '0009_auto_20180729_0503'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RenameField( |
||||
model_name='config', |
||||
old_name='REFERRAL_DISCOUNT', |
||||
new_name='REFERRAL_BONUS', |
||||
), |
||||
migrations.RenameField( |
||||
model_name='config', |
||||
old_name='REFERRER_CASHBACK', |
||||
new_name='REFERRER_BONUS', |
||||
), |
||||
] |
||||
@ -0,0 +1,23 @@ |
||||
# Generated by Django 2.0.6 on 2018-09-03 22:57 |
||||
|
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0019_payment_roistat_visit'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='UserBonus', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('amount', models.DecimalField(decimal_places=2, default=0, editable=False, max_digits=8)), |
||||
('created_at', models.DateTimeField(auto_now_add=True)), |
||||
('payment', models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, to='payment.Payment')), |
||||
], |
||||
), |
||||
] |
||||
@ -0,0 +1,27 @@ |
||||
# Generated by Django 2.0.6 on 2018-09-03 22:57 |
||||
|
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('user', '0024_referral'), |
||||
('payment', '0020_userbonus'), |
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='userbonus', |
||||
name='referral', |
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='user.Referral'), |
||||
), |
||||
migrations.AddField( |
||||
model_name='userbonus', |
||||
name='user', |
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bonuses', to=settings.AUTH_USER_MODEL), |
||||
), |
||||
] |
||||
@ -0,0 +1,19 @@ |
||||
# Generated by Django 2.0.6 on 2018-09-04 01:06 |
||||
|
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0021_auto_20180903_2257'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AlterField( |
||||
model_name='userbonus', |
||||
name='payment', |
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='payment.Payment'), |
||||
), |
||||
] |
||||
@ -0,0 +1,19 @@ |
||||
# Generated by Django 2.0.6 on 2018-09-05 23:37 |
||||
|
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0022_auto_20180904_0106'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='payment', |
||||
name='bonus', |
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='purchase_payments', to='payment.UserBonus'), |
||||
), |
||||
] |
||||
@ -0,0 +1,31 @@ |
||||
# Generated by Django 2.0.6 on 2018-09-03 22:57 |
||||
|
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('payment', '0020_userbonus'), |
||||
('user', '0023_user_trial_lesson'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='Referral', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('bonus', models.IntegerField()), |
||||
('referrer_bonus', models.IntegerField()), |
||||
('payment', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='payment.Payment')), |
||||
('referral', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='referral', to=settings.AUTH_USER_MODEL)), |
||||
('referrer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='referrals', to=settings.AUTH_USER_MODEL)), |
||||
], |
||||
options={ |
||||
'verbose_name': 'Реферал', |
||||
'verbose_name_plural': 'Рефералы', |
||||
}, |
||||
), |
||||
] |
||||
@ -0,0 +1,14 @@ |
||||
<div class="section section_gray section_menu"> |
||||
<div class="section__center center center_xs"> |
||||
<div class="menu"> |
||||
<a class="menu__link {% if active == 'profile' %}active{% endif %}" |
||||
href="{% url 'user-edit-profile' %}">Профиль</a> |
||||
<a class="menu__link {% if active == 'notifications' %}active{% endif %}" |
||||
href="{% url 'user-edit-notifications' %}">Уведомления</a> |
||||
<a class="menu__link {% if active == 'payments' %}active{% endif %}" |
||||
href="{% url 'user-edit-payments' %}">Платежи</a> |
||||
<!--<a class="menu__link {% if active == 'bonuses' %}active{% endif %}"--> |
||||
<!--href="{% url 'user-bonuses' %}">Бонусы</a>--> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,71 @@ |
||||
{% extends "templates/lilcity/index.html" %} |
||||
{% load static %} |
||||
{% load rupluralize from plural %} |
||||
|
||||
{% block content %} |
||||
{% include "../blocks/profile-menu.html" with active="bonuses" %} |
||||
|
||||
<div class="section section_gray" style="padding-bottom: 0;"> |
||||
<div class="section__center center center_xs"> |
||||
<div class="title title_sm">Бонусы</div> |
||||
<div class="text">У вас {{ request.user.bonus|rupluralize:"бонус,бонуса,бонусов" }}</div> |
||||
<div> |
||||
Вы можете пригласить своих друзей в наш сервис, за это |
||||
{% if config.REFERRER_BONUS == config.REFERRAL_BONUS %} |
||||
вы и они получите по {{ config.REFERRER_BONUS }}% |
||||
{% else %} |
||||
вы получите {{ config.REFERRER_BONUS }}%, а они {{ config.REFERRAL_BONUS }}% |
||||
{% endif %} |
||||
от суммы их первой покупки на бонусный счет. Приглашайте друзей, накапливайте бонусные баллы, тратьте бонусы |
||||
на приобретения доступа к школе и курсам. Оплата услуг возможна только, если вы накопили баллов на стоимость услуги. |
||||
<br> |
||||
Просто отправьте им эту ссылку, по которой они смогут зарегистрироваться: |
||||
</div> |
||||
<div class="form__field field" style="margin-bottom: 0;"> |
||||
<div class="field__wrap"> |
||||
<input id="referrer-url" class="field__input" type="text" value="{{ referrer_url }}" readonly="readonly"> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="section section_gray"> |
||||
<div class="section__center center center_sm"> |
||||
<div class="title title_sm">История бонусов</div> |
||||
<div class="transactions transactions_bonuses"> |
||||
<div class="transactions__wrap"> |
||||
<div class="transactions__row"> |
||||
<div class="transactions__cell transactions__product">Продукт</div> |
||||
<div class="transactions__cell transactions__amount">Сумма покупки</div> |
||||
<div class="transactions__cell transactions__user">Реферал</div> |
||||
<div class="transactions__cell transactions__amount">Сумма бонусов</div> |
||||
</div> |
||||
{% for bonus in bonuses %} |
||||
<div class="transactions__row"> |
||||
{% with payment=bonus.payment %} |
||||
{% if payment.course %} |
||||
<div class="transactions__cell transactions__product">Курс. {{ payment.course.title }}</div> |
||||
{% else %} |
||||
<div class="transactions__cell transactions__product"> |
||||
{% if request.user_agent.is_mobile %} |
||||
Школа. {% if payment.date_start and payment.date_end %}{{ payment.date_start|date:"j b" }} - {{ payment.date_end|date:"j b" }}{% endif %} |
||||
{% else %} |
||||
Школа. {% if payment.date_start and payment.date_end %}{{ payment.date_start }} - {{ payment.date_end }}{% endif %} |
||||
{% endif %} |
||||
</div> |
||||
{% endif %} |
||||
<div class="transactions__cell transactions__amount">{{payment.amount }}</div> |
||||
<div class="transactions__cell transactions__user"> |
||||
{% if bonus.referral %}{{ bonus.referral.referral.get_full_name }}{% endif %} |
||||
</div> |
||||
<div class="transactions__cell transactions__amount">{{ bonus.amount|floatformat }}</div> |
||||
{% endwith %} |
||||
</div> |
||||
{% empty %} |
||||
Нет истории бонусов |
||||
{% endfor %} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
||||
@ -0,0 +1,5 @@ |
||||
export const rupluralize = (value, args) => { |
||||
let digit = Math.trunc(value) + ''; |
||||
digit = digit[digit.length - 1]; |
||||
return value + ' ' + args[digit == '1' ? 0 : ('234'.search(digit) > -1 ? 1 : 2)]; |
||||
} |
||||
Loading…
Reference in new issue