remotes/origin/PR-39
PekopT 10 years ago
parent 60bffa4337
commit 6b0bc1593a
  1. 8
      ratings/templates/templatetags/ratings_widget.html
  2. 37
      ratings/templates/templatetags/specializations_widget.html
  3. 18
      ratings/templatetags/specializtions_tags.py
  4. 58
      users/templates/contractor_office.html
  5. 9
      users/templates/contractor_profile.html
  6. 1
      users/views.py
  7. 42
      wallets/views.py

@ -1,12 +1,12 @@
<ul class="rettList {{ class_name }}"> <ul class="rettList {{ class_name }}">
<li>Рейтинг: <span> {{ ratings }}</span></li> <li>Рейтинг: <span> {{ ratings }}</span></li>
<li>Безопасные сделки: <span> 0</span></li> <li>Безопасные сделки: <span> {{ deals }}</span></li> {# TODO #}
<li> <li>
<a href="javascript:void(0)"> <a href="javascript:void(0)">
Отзывы: Отзывы:
<span> + 0</span> <span> + {{ reviews_p }}</span>
<small> 0</small> <small> {{ reviews_n }}</small>
<mark> - 0</mark> <mark> - {{ reviews_m }}</mark>
</a> </a>
</li> </li>
</ul> </ul>

@ -1,38 +1,3 @@
{#<!-- Новая вёрстка ---------------------------------------------------->#}
{##}
{# <div class="dashedCol4 dashedCol44">#}
{# <p class="specUser">#}
{# Специализации:#}
{# </p>#}
{# <div class="insetSpec">#}
{# <span>Интерьеры</span>#}
{# <span>2-й</span>#}
{# </div>#}
{# <div class="insetSpec">#}
{# <span>Визуализация/3D</span>#}
{# <span>45-й</span>#}
{# </div>#}
{# <div class="insetSpec">#}
{# <span>Экстерьеры</span>#}
{# <span>10-й</span>#}
{# </div>#}
{# <div class="showSpec">#}
{# <div class="insetSpec">#}
{# <span>Архитектура</span>#}
{# <span>3-й</span>#}
{# </div>#}
{# <div class="insetSpec">#}
{# <span>3D Моделирование</span>#}
{# <span>100-й</span>#}
{# </div>#}
{# </div>#}
{# <button class="showPress">#}
{# #}
{# </button>#}
{# </div>#}
<div class="dashedCol4"> <div class="dashedCol4">
<p class="specUser">Специализации:</p> <p class="specUser">Специализации:</p>
{% for spec in specializations %} {% for spec in specializations %}
@ -40,5 +5,7 @@
<span>{{ spec.specialization.name }}</span> <span>{{ spec.specialization.name }}</span>
<span>{{ spec.position }}-й</span> <span>{{ spec.position }}-й</span>
</div> </div>
{% empty %}
Рейтинги скоро будут рассчитаны
{% endfor %} {% endfor %}
</div> </div>

@ -1,11 +1,13 @@
from django import template from django import template
from archilance import util from projects.models import Order
from users.models import User, Team
from ratings.models import SpecializationRating from ratings.models import SpecializationRating
from reviews.models import Review
from users.models import User, Team
register = template.Library() register = template.Library()
@register.inclusion_tag('templatetags/specializations_widget.html', takes_context=True) @register.inclusion_tag('templatetags/specializations_widget.html', takes_context=True)
def specialization_widget(context, user_id, class_name=None): def specialization_widget(context, user_id, class_name=None):
user_id = int(user_id) user_id = int(user_id)
@ -25,18 +27,26 @@ def specialization_team_widget(context, team_id):
} }
@register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) @register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True)
def ratings_widget(context, user_id, class_name=None): def ratings_widget(context, user_id, class_name=None):
ratings = User.objects.get(pk=user_id).rating ratings = User.objects.get(pk=user_id).rating
return { return {
'ratings': ratings, 'ratings': ratings,
'class_name': class_name 'class_name': class_name,
'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(),
'reviews_m': Review.objects.filter(target_contractor_id=user_id, type='negative').count(),
'reviews_p': Review.objects.filter(target_contractor_id=user_id, type='positive').count(),
} }
@register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) @register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True)
def ratings_team_widget(context, team_id): def ratings_team_widget(context, team_id):
ratings = Team.objects.get(pk=team_id).rating ratings = Team.objects.get(pk=team_id).rating
return { return {
'ratings': ratings, 'ratings': ratings,
'deals': Order.objects.filter(secure=True, team_id=team_id, status=1).count(),
'reviews_n': Review.objects.filter(target_team_id=team_id, type='neutral').count(),
'reviews_m': Review.objects.filter(target_team_id=team_id, type='negative').count(),
'reviews_p': Review.objects.filter(target_team_id=team_id, type='positive').count(),
} }

@ -91,7 +91,8 @@
<span>Программист</span> <span>Программист</span>
</div> </div>
{% empty %}
В группе пока нет участников
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
@ -176,15 +177,19 @@
</div> </div>
</div> </div>
</div> </div>
{% empty %}
<div class="col-lg-12">
<p style="text-align: center;margin-top: 25px;">Работ в портфолио пока нет</p>
</div>
{% endfor %} {% endfor %}
</div> </div>
{# TODO:#}
<div class="col-lg-9 col-lg-offset-3"> {# <div class="col-lg-9 col-lg-offset-3">#}
<div class="linkElse"> {# <div class="linkElse">#}
<a href="javascript:void(0)" class="showElse">показать еще</a> {# <a href="javascript:void(0)" class="showElse">показать еще</a>#}
</div> {# </div>#}
</div> {# </div>#}
</div> </div>
<div id="tab12" class="tab-pane fade"> <div id="tab12" class="tab-pane fade">
@ -208,38 +213,45 @@
</div> </div>
</div> </div>
{% empty %}
<div class="col-lg-12">
<p style="text-align: center;margin-top: 25px;">Готовых работ пока нет</p>
</div>
{% endfor %} {% endfor %}
</div> </div>
<div class="col-lg-9 col-lg-offset-3"> {# TODO#}
<div class="linkElse"> {# <div class="col-lg-9 col-lg-offset-3">#}
<a href="javascript:void(0)" class="showElse">показать еще</a> {# <div class="linkElse">#}
</div> {# <a href="javascript:void(0)" class="showElse">показать еще</a>#}
</div> {# </div>#}
{# </div>#}
</div> </div>
<div id="tab13" class="tab-pane fade"> <div id="tab13" class="tab-pane fade">
{% for review in reviews %}
<div class="new-comm-44"> <div class="new-comm-44">
<div class="col-lg-12"> <div class="col-lg-12">
<p class="nameComm"> <p class="nameComm">
<a href="#">Иванов Петр Иванович</a> <a href="">{{ review.get_sender }}</a>
</p> </p>
<span class="dateComm44"> {% if review.project.deal_type == 'secure_deal' %}
Безопасная сделка <span class="dateComm44">
</span> Безопасная сделка
</span>
{% endif %}
<div class="stars box-sizing"> <div class="stars box-sizing">
<span class="glyphicon glyphicon-star starAct" aria-hidden="true"></span>
<span class="glyphicon glyphicon-star starAct" aria-hidden="true"></span>
<span class="glyphicon glyphicon-star starAct" aria-hidden="true"></span>
<span class="glyphicon glyphicon-star" aria-hidden="true"></span>
<span class="glyphicon glyphicon-star" aria-hidden="true"></span>
<a href="#">положительный отзыв</a> <a href="#">положительный отзыв</a>
</div> </div>
<p class="textComm44"> <p class="textComm44">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum {{ review.text|safe }}
</p> </p>
</div> </div>
</div> </div>
{% empty %}
<div class="new-comm-44">
<p style="text-align: center;">Отзывов пока нет</p>
</div>
{% endfor %}
</div> </div>
</div> </div>
</div> </div>

@ -196,7 +196,12 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% empty %}
<div class="col-lg-4">
<p style="text-align: center;">Работ в портфолио пока нет</p>
</div>
{% endfor %} {% endfor %}
</div> </div>
<div class="col-lg-9 col-lg-offset-3"> <div class="col-lg-9 col-lg-offset-3">
@ -455,6 +460,10 @@
</p> </p>
</div> </div>
</div> </div>
{% empty %}
<div class="new-comm-44">
<p style="text-align: center;">Отзывов пока нет</p>
</div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

@ -375,6 +375,7 @@ class ContractorOfficeDetailView(DetailView):
work_sells = WorkSell.objects.filter(contractor__in=user_ids) work_sells = WorkSell.objects.filter(contractor__in=user_ids)
context['portfolios'] = portfolios context['portfolios'] = portfolios
context['work_sells'] = work_sells context['work_sells'] = work_sells
context['reviews'] = Review.objects.filter(target_contractor__in=user_ids)
return context return context

@ -1,27 +1,25 @@
from django.conf import urls, settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Sum from django.db.models import Sum
from django.http import HttpResponse, JsonResponse, HttpResponseForbidden from django.http import HttpResponse, JsonResponse
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.utils import timezone from django.utils import timezone
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.generic import DetailView, CreateView from django.views.generic import DetailView, CreateView
from django.views.generic.base import View from django.views.generic.base import View
from pprint import pprint, pformat
import logging
from users.models import User
from .forms import WithDrawForm, TmpCheckOrderForm, TmpPaymentAvisoForm from .forms import WithDrawForm, TmpCheckOrderForm, TmpPaymentAvisoForm
from .models import InvoiceHistory, WithDraw, Transaction from .models import InvoiceHistory, WithDraw, Transaction
from users.mixins import CheckForUserMixin
from users.models import User
class ScoreDetailView(DetailView): class ScoreDetailView(DetailView):
model = User model = User
template_name = 'score-detail.html' template_name = 'score-detail.html'
context_object_name = 'user_score' context_object_name = 'user_score'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
user_score_balance = InvoiceHistory.objects.filter(user=self.get_object()).aggregate(Sum('sum')) user_score_balance = InvoiceHistory.objects.filter(user=self.get_object()).aggregate(Sum('sum'))
@ -30,16 +28,15 @@ class ScoreDetailView(DetailView):
return context return context
class ScoreView(View): class ScoreView(LoginRequiredMixin, View):
template_name = 'score-detail.html' template_name = 'score-detail.html'
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
# transaction = Transaction.objects.get_or_create(customer=request.user, complete=False) transaction = Transaction.objects.create(customer=request.user, type='add')
transaction = Transaction.objects.create(customer=request.user,type='add')
user_score = get_object_or_404(User.objects, pk=kwargs.get('pk')) user_score = get_object_or_404(User.objects, pk=kwargs.get('pk'))
current_sum_info = InvoiceHistory.objects.filter(user=user_score).aggregate(Sum('sum')) current_sum_info = InvoiceHistory.objects.filter(user=user_score).aggregate(Sum('sum'))
user_score_balance = current_sum_info['sum__sum'] or 0 user_score_balance = current_sum_info['sum__sum'] or 0
return render(request, self.template_name, { return render(request, self.template_name, {
'transaction': transaction, 'transaction': transaction,
'YANDEX_MONEY': settings.YANDEX_MONEY, 'YANDEX_MONEY': settings.YANDEX_MONEY,
@ -96,23 +93,22 @@ class WithDrawCreate(CreateView):
return super().form_invalid(form) return super().form_invalid(form)
# Yandex Money ------------------------------------------------ # Yandex Money ------------------------------------------------
class TmpCheckOrderView(View): class TmpCheckOrderView(View):
form_class = TmpCheckOrderForm form_class = TmpCheckOrderForm
@method_decorator(csrf_exempt) @method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.form_class(request.POST) form = self.form_class(request.POST)
# trans = form.cleaned_data.get('transaction') # trans = form.cleaned_data.get('transaction')
if form.is_valid(): if form.is_valid():
res = """<?xml version="1.0" encoding="utf-8"?> res = """<?xml version="1.0" encoding="utf-8"?>
<checkOrderResponse <checkOrderResponse
@ -125,7 +121,7 @@ class TmpCheckOrderView(View):
invoice_id=form.cleaned_data.get('invoiceId'), invoice_id=form.cleaned_data.get('invoiceId'),
shop_id=form.cleaned_data.get('shopId'), shop_id=form.cleaned_data.get('shopId'),
) )
return HttpResponse(res, content_type='application/xml') return HttpResponse(res, content_type='application/xml')
else: else:
res = """<?xml version="1.0" encoding="utf-8"?> res = """<?xml version="1.0" encoding="utf-8"?>
@ -141,21 +137,21 @@ class TmpCheckOrderView(View):
invoice_id=form.cleaned_data.get('invoiceId'), invoice_id=form.cleaned_data.get('invoiceId'),
shop_id=form.cleaned_data.get('shopId'), shop_id=form.cleaned_data.get('shopId'),
) )
return HttpResponse(res, content_type='application/xml') return HttpResponse(res, content_type='application/xml')
# return HttpResponse('<pre>{msg}</pre>'.format(msg=pformat(form.errors))) # Debug # return HttpResponse('<pre>{msg}</pre>'.format(msg=pformat(form.errors))) # Debug
class TmpPaymentAvisoView(View): class TmpPaymentAvisoView(View):
form_class = TmpPaymentAvisoForm form_class = TmpPaymentAvisoForm
@method_decorator(csrf_exempt) @method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.form_class(request.POST) form = self.form_class(request.POST)
if form.is_valid(): if form.is_valid():
transaction = form.cleaned_data.get('transaction_id') transaction = form.cleaned_data.get('transaction_id')
transaction.complete = True transaction.complete = True
@ -173,7 +169,7 @@ class TmpPaymentAvisoView(View):
invoice_id=form.cleaned_data.get('invoiceId'), invoice_id=form.cleaned_data.get('invoiceId'),
shop_id=form.cleaned_data.get('shopId'), shop_id=form.cleaned_data.get('shopId'),
) )
return HttpResponse(res, content_type='application/xml') return HttpResponse(res, content_type='application/xml')
else: else:
res = """<?xml version="1.0" encoding="utf-8"?> res = """<?xml version="1.0" encoding="utf-8"?>
@ -183,6 +179,6 @@ class TmpPaymentAvisoView(View):
message="Payment aviso, validation error" message="Payment aviso, validation error"
techMessage="Payment aviso, validation error"/> techMessage="Payment aviso, validation error"/>
""".format(date=timezone.now().isoformat()) """.format(date=timezone.now().isoformat())
return HttpResponse(res, content_type='application/xml') return HttpResponse(res, content_type='application/xml')
# return HttpResponse('<pre>{msg}</pre>'.format(msg=pformat(form.errors))) # Debug # return HttpResponse('<pre>{msg}</pre>'.format(msg=pformat(form.errors))) # Debug

Loading…
Cancel
Save