fixes count and review errors

remotes/origin/PR-39
Mukhtar 9 years ago
parent 7c03320f03
commit 00cbebac06
  1. 2
      assets/js/chat.js
  2. 5
      projects/forms.py
  3. 5
      reviews/serializers.py
  4. 3
      users/templates/partials/customer_profile_info_block.html
  5. 10
      users/templatetags/user_tags.py

@ -781,7 +781,7 @@ function dialog (message, yesCallback, notCallback) {
console.log(json);
$("#review-add").modal('hide');
$("#leaveReview").hide();
var currOrder = json.project;
var currOrder = json.order;
var currRecipent = json.target_user;
socket.send_stages_approve({

@ -83,6 +83,7 @@ class ProjectFilterRealtyForm(forms.ModelForm):
self.fields['construction_type'].required = False
self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants()
self.fields['building_classification'].queryset = BuildingClassfication.objects.root_nodes()[0].get_descendants()
# self.fields['location'].queryset = Location.objects # Migrate with this enabled
@ -150,8 +151,8 @@ class CustomerProjectEditForm(forms.ModelForm):
class RealtyForm(forms.ModelForm):
building_classification = TreeNodeChoiceField(
BuildingClassfication.objects.all(),
label="", initial='',
BuildingClassfication.objects.exclude(name='_root'),
label="ll", initial='',
widget=forms.Select(attrs={
'class': 'selectpicker',
'id': 'realtyBuildingClassificationId'

@ -7,6 +7,7 @@ from users.serializers import UserSerializer, TeamSerializer
class ReviewSerializer(ModelSerializer):
target_user = serializers.SerializerMethodField(read_only=True)
order = serializers.SerializerMethodField(read_only=True)
class Meta:
model = Review
@ -24,8 +25,12 @@ class ReviewSerializer(ModelSerializer):
'target_contractor',
'target_team',
'target_user',
'order',
)
def get_order(self, obj):
return obj.project.order.pk
def get_target_user(self, obj):
if obj.target_customer:
return obj.target_customer.pk

@ -1,5 +1,6 @@
{% load specializtions_tags %}
{% load thumbnail %}
{% load user_tags %}
<div class="col-lg-12">
@ -68,7 +69,7 @@
<a href="{{ c }}">Отзывы</a>
<div class="roundsCount">
<div class="countG">0</div>
<div class="countG">{% get_reviews_count request.user %}</div>
</div>
</li>
</ul>

@ -1,6 +1,7 @@
import math
from django import template
from chat.models import NewMessage
from reviews.models import Review
register = template.Library()
@ -84,3 +85,12 @@ def get_new_count_for_team(current_user, team_id, order_id=None):
return count
@register.simple_tag
def get_reviews_count(user):
if user.is_customer():
count = Review.objects.filter(target_customer=user).count()
else:
count = Review.objects.filter(target_contractor=user).count()
return count

Loading…
Cancel
Save