diff --git a/users/templates/partials/inc-customer_profile-info.html b/users/templates/partials/inc-customer_profile-info.html index e04c31a..d07e114 100644 --- a/users/templates/partials/inc-customer_profile-info.html +++ b/users/templates/partials/inc-customer_profile-info.html @@ -39,7 +39,7 @@ - + @@ -58,8 +58,16 @@ {% endif %} -
-
На сайте:{{ customer.created }}{{ on_site }}
Страна:
+
+ {% if request.user.is_authenticated %} + + Показать контакты + + {% endif %} +
Рейтинг:
diff --git a/users/templates/partials/modals/mod-customer-contacts.html b/users/templates/partials/modals/mod-customer-contacts.html new file mode 100644 index 0000000..79c9e70 --- /dev/null +++ b/users/templates/partials/modals/mod-customer-contacts.html @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/users/views.py b/users/views.py index 7c7cf33..3ff61dd 100644 --- a/users/views.py +++ b/users/views.py @@ -2,6 +2,7 @@ import itertools import json import re from pprint import pformat +import datetime from .signals import * import natsort @@ -803,8 +804,19 @@ class CustomerProfileView(BaseMixin, DetailView): context = super().get_context_data() user_id = self.kwargs['pk'] # profile-info + user_created = self.model.objects.get(pk=user_id).created + now = datetime.datetime.now() + dt = now - user_created.replace(tzinfo=None) + + # TODO: Реализация не учитывает разное кол-во дней в месяцах + if dt.days <= 30: + on_site = '{} {}'.format(dt.days, util.morph(dt.days, ["день", "дня", "дней"])) + else: + months = math.floor(dt.days / 30) + on_site = '{} {}'.format(months, util.morph(months, ["месяц", "месяца", "месяцев"])) context.update( { + 'on_site': on_site, 'ratings': self.model.objects.get(pk=user_id).rating, 'deals': Order.objects.filter(secure=True, contractor_id=user_id, status=1).count(), 'reviews_n': Review.objects.filter(target_contractor_id=user_id, type='neutral').count(),