update cabinet app

remotes/origin/HEAD
Max Yakovenko 8 years ago
parent d82e6ebd90
commit 0547ed23ba
  1. 2
      cabinet/urls.py
  2. 14
      cabinet/views.py
  3. 26
      templates/cabinet/index.html

@ -3,5 +3,5 @@ from django.urls import re_path
from . import views from . import views
urlpatterns = [ urlpatterns = [
re_path(r'^index/$', views.IndexView.as_view(), name='index') re_path(r'^index/$', views.IndexTemplateView.as_view(), name='index')
] ]

@ -3,13 +3,11 @@ from django.core.paginator import Paginator
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
# Create your views here. # 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 IndexTemplateView(ProtectedTemplateView):
class IndexView(ProtectedView):
template_name = 'cabinet/index.html' template_name = 'cabinet/index.html'
title = _('Личный кабинет') title = _('Личный кабинет')
@ -20,7 +18,7 @@ class IndexView(ProtectedView):
}) })
def get_bought_item_list(self,user): 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( paginator = Paginator(
object_list=bought_item_queryset, object_list=bought_item_queryset,
per_page=5 per_page=5
@ -35,6 +33,9 @@ class IndexView(ProtectedView):
'patronymic': user.profile.patronymic or "" 'patronymic': user.profile.patronymic or ""
}) })
def get_user_points(self,user):
return user.referral.referralstats.points
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context['title'] = self.title context['title'] = self.title
@ -45,4 +46,5 @@ class IndexView(ProtectedView):
context['phone_number'] = self.request.user.profile.phone context['phone_number'] = self.request.user.profile.phone
context['company'] = self.request.user.company or None context['company'] = self.request.user.company or None
context['profile'] = self.request.user.profile or None context['profile'] = self.request.user.profile or None
context['referral_points'] = self.get_user_points(user=self.request.user)
return context return context

@ -9,14 +9,16 @@
<div class="cabinet__bonus"> <div class="cabinet__bonus">
<div class="d-sm-flex flex-row cabinet__wrap"> <div class="d-sm-flex flex-row cabinet__wrap">
<div class="cabinet__title bonus__title"> <div class="cabinet__title bonus__title">
Ваши бонусы: <span>1326</span> Ваши бонусы: <span>{{ referral_points }}</span>
</div> </div>
{% if referral_points > 0 %}
<div class="bonus__btn_bx flex-xl-fill"> <div class="bonus__btn_bx flex-xl-fill">
<a href="#" class="cabinet__link_fill">Вывести бонусы</a> <a href="#" class="cabinet__link_fill">Вывести бонусы</a>
</div> </div>
<div class="bonus__btn_bx"> <div class="bonus__btn_bx">
<a href="#" class="cabinet__link_fill">Потратить на подарки</a> <a href="#" class="cabinet__link_fill">Потратить на подарки</a>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
<div class="d-sm-flex flex-row cabinet__wrap"> <div class="d-sm-flex flex-row cabinet__wrap">
@ -31,6 +33,7 @@
<div class="col-lg-5 offset-lg-1 col-122"> <div class="col-lg-5 offset-lg-1 col-122">
<div class="cabinet__friends"> <div class="cabinet__friends">
<div class="cabinet__title">Приглашенные друзья</div> <div class="cabinet__title">Приглашенные друзья</div>
{% if refeferall_user_list > 0 %}
<div class="d-flex flex-row friends__row"> <div class="d-flex flex-row friends__row">
<div class="friends__title_header">Имя</div> <div class="friends__title_header">Имя</div>
<div class="friends__info_header">Баллы</div> <div class="friends__info_header">Баллы</div>
@ -40,12 +43,10 @@
<div class="friends__title">{{ ref_user.name }}</div> <div class="friends__title">{{ ref_user.name }}</div>
<div class="friends__info">{{ ref_user }}</div> <div class="friends__info">{{ ref_user }}</div>
</div> </div>
{% empty %}
<div class="d-flex flex-row friends__row">
<div class="friends__title">Nikolas</div>
<div class="friends__info">120</div>
</div>
{% endfor %} {% endfor %}
{% else %}
Вы еще никого не пригласили :((
{% endif %}
</div> </div>
</div> </div>
</div> </div>
@ -70,19 +71,16 @@
<td>{{ bought_item.amount }}</td> <td>{{ bought_item.amount }}</td>
<td>{{ bought_item.total_price }}7570₽</td> <td>{{ bought_item.total_price }}7570₽</td>
</tr> </tr>
{% empty %}
<tr>
<td>12.06.17</td>
<td>142251366</td>
<td>Windows 7 BOX...</td>
<td>1</td>
<td>7570₽</td>
</tr>
{% endfor %} {% endfor %}
</table> </table>
{% if bought_item_list > 0 %}
<div class="history__btn_bx"> <div class="history__btn_bx">
<a href="{% url 'cart:history' %}" class="cabinet__link_fill">Вся история покупок</a> <a href="{% url 'cart:history' %}" class="cabinet__link_fill">Вся история покупок</a>
</div> </div>
{% else %}
<div class="cabinet__title">У вас отсутствуют покупки</div>
{% endif %}
</div> </div>
<div class="cabinet__userdata"> <div class="cabinet__userdata">
<div class="d-flex flex-row userdata_row"> <div class="d-flex flex-row userdata_row">

Loading…
Cancel
Save