diff --git a/cabinet/urls.py b/cabinet/urls.py
index a11abae..68933e8 100644
--- a/cabinet/urls.py
+++ b/cabinet/urls.py
@@ -3,5 +3,5 @@ from django.urls import re_path
from . import views
urlpatterns = [
- re_path(r'^index/$', views.IndexView.as_view(), name='index')
+ re_path(r'^index/$', views.IndexTemplateView.as_view(), name='index')
]
diff --git a/cabinet/views.py b/cabinet/views.py
index 2328b7b..1848e2a 100644
--- a/cabinet/views.py
+++ b/cabinet/views.py
@@ -3,13 +3,11 @@ from django.core.paginator import Paginator
from django.utils.translation import ugettext_lazy as _
# Create your views here.
-from django.views.generic import ListView
+from cart.models import BUYING_STATUS_PAID
+from core.views import ProtectedTemplateView
-from cart.models import BUYING_STATUS_IN_CART, BUYING_STATUS_BOUGHT, Buying
-from core.views import ProtectedView
-
-class IndexView(ProtectedView):
+class IndexTemplateView(ProtectedTemplateView):
template_name = 'cabinet/index.html'
title = _('Личный кабинет')
@@ -20,7 +18,7 @@ class IndexView(ProtectedView):
})
def get_bought_item_list(self,user):
- bought_item_queryset = user.buying_set.filter(status=BUYING_STATUS_BOUGHT).order_by('-create_at').all()
+ bought_item_queryset = user.buying_set.filter(status=BUYING_STATUS_PAID).order_by('-create_at').all()
paginator = Paginator(
object_list=bought_item_queryset,
per_page=5
@@ -35,6 +33,9 @@ class IndexView(ProtectedView):
'patronymic': user.profile.patronymic or ""
})
+ def get_user_points(self,user):
+ return user.referral.referralstats.points
+
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title'] = self.title
@@ -45,4 +46,5 @@ class IndexView(ProtectedView):
context['phone_number'] = self.request.user.profile.phone
context['company'] = self.request.user.company or None
context['profile'] = self.request.user.profile or None
+ context['referral_points'] = self.get_user_points(user=self.request.user)
return context
diff --git a/templates/cabinet/index.html b/templates/cabinet/index.html
index 04b39e7..782129e 100644
--- a/templates/cabinet/index.html
+++ b/templates/cabinet/index.html
@@ -9,19 +9,21 @@
- Ваши бонусы: 1326
-
-
-
+ {% if referral_points > 0 %}
+
+
+ {% endif %}
Скопировать
@@ -31,21 +33,20 @@
Приглашенные друзья
-
-
-
-
- {% for ref_user in referral_user_list %}
+ {% if refeferall_user_list > 0 %}
-
{{ ref_user.name }}
-
{{ ref_user }}
+
+
- {% empty %}
-
- {% endfor %}
+ {% for ref_user in referral_user_list %}
+
+
{{ ref_user.name }}
+
{{ ref_user }}
+
+ {% endfor %}
+ {% else %}
+ Вы еще никого не пригласили :((
+ {% endif %}
@@ -70,19 +71,16 @@
{{ bought_item.amount }} |
{{ bought_item.total_price }}7570₽ |
- {% empty %}
-
- | 12.06.17 |
- 142251366 |
- Windows 7 BOX... |
- 1 |
- 7570₽ |
-
{% endfor %}
-
+
+ {% if bought_item_list > 0 %}
+
+ {% else %}
+
У вас отсутствуют покупки
+ {% endif %}
@@ -102,14 +100,14 @@
{{ email }}
-{# #}
-{#
Ближайшие продления
#}
-{#
#}
-{#
Windows 7...
#}
-{#
22.07.2018 (!)
#}
-{#
#}
-{#
#}
-{#
#}
+ {# #}
+ {#
Ближайшие продления
#}
+ {#
#}
+ {#
Windows 7...
#}
+ {#
22.07.2018 (!)
#}
+ {#
#}
+ {#
#}
+ {#
#}
@@ -158,26 +156,26 @@
{{ profile.phone|default:'-' }}
-{# #}
-{#
Продлеваемые продукты
#}
-{#
#}
-{# #}
-{# | Продукт | #}
-{# Количество | #}
-{# Дата окончания | #}
-{#
#}
-{# #}
-{# | Windows 7... | #}
-{# 1 | #}
-{# 22.07.2018 | #}
-{#
#}
-{# #}
-{# | Windows 7... | #}
-{# 1 | #}
-{# 22.07.2018 | #}
-{#
#}
-{#
#}
-{#
#}
+ {# #}
+ {#
Продлеваемые продукты
#}
+ {#
#}
+ {# #}
+ {# | Продукт | #}
+ {# Количество | #}
+ {# Дата окончания | #}
+ {#
#}
+ {# #}
+ {# | Windows 7... | #}
+ {# 1 | #}
+ {# 22.07.2018 | #}
+ {#
#}
+ {# #}
+ {# | Windows 7... | #}
+ {# 1 | #}
+ {# 22.07.2018 | #}
+ {#
#}
+ {#
#}
+ {#
#}
@@ -186,11 +184,11 @@
{% block extra_body_js %}