|
|
|
|
@ -3,12 +3,10 @@ from django.core.paginator import Paginator |
|
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
|
|
|
|
|
|
# Create your views here. |
|
|
|
|
from cart.models import BUYING_STATUS_IN_CART |
|
|
|
|
from core.views import ProtectedView |
|
|
|
|
|
|
|
|
|
from django.views.generic import ListView |
|
|
|
|
|
|
|
|
|
def get_mobile_phone_number(user): |
|
|
|
|
return user.profile.phone |
|
|
|
|
from cart.models import BUYING_STATUS_IN_CART, BUYING_STATUS_BOUGHT, Buying |
|
|
|
|
from core.views import ProtectedView |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class IndexView(ProtectedView): |
|
|
|
|
@ -16,11 +14,18 @@ class IndexView(ProtectedView): |
|
|
|
|
title = _('Личный кабинет') |
|
|
|
|
|
|
|
|
|
def get_ref_link(self,user): |
|
|
|
|
return user.referral.url if user.referral else "" |
|
|
|
|
return "{path}?ref={ref_link}".format(**{ |
|
|
|
|
'path': user.referral.url, |
|
|
|
|
'ref_link': user.referral.code |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
def get_bought_item_list(self,user): |
|
|
|
|
paginator = Paginator(object_list=user.buying_set.filter(status=BUYING_STATUS_IN_CART).order_by('create_at').all(), per_page=settings.DEFAULT_PAGE_AMMOUNT) |
|
|
|
|
the_page = self.kwargs.get('page',1) |
|
|
|
|
bought_item_queryset = user.buying_set.filter(status=BUYING_STATUS_BOUGHT).order_by('-create_at').all() |
|
|
|
|
paginator = Paginator( |
|
|
|
|
object_list=bought_item_queryset, |
|
|
|
|
per_page=5 |
|
|
|
|
) |
|
|
|
|
the_page = 1 |
|
|
|
|
return paginator.page(the_page) |
|
|
|
|
|
|
|
|
|
def get_full_name(self,user): |
|
|
|
|
@ -38,4 +43,6 @@ class IndexView(ProtectedView): |
|
|
|
|
context['full_name'] = self.get_full_name(self.request.user) |
|
|
|
|
context['email'] = self.request.user.email |
|
|
|
|
context['phone_number'] = self.request.user.profile.phone |
|
|
|
|
context['company'] = self.request.user.company |
|
|
|
|
context['profile'] = self.request.user.profile |
|
|
|
|
return context |
|
|
|
|
|