|
|
|
|
@ -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 |
|
|
|
|
|