|
|
|
|
@ -1,9 +1,13 @@ |
|
|
|
|
from chat.models import NewMessage |
|
|
|
|
from django import template |
|
|
|
|
from django.core.paginator import Page |
|
|
|
|
from django.db.models import Count |
|
|
|
|
from django.db.models import Q, Count |
|
|
|
|
import math |
|
|
|
|
|
|
|
|
|
from reviews.models import Review |
|
|
|
|
from projects.models import Order |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register = template.Library() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -86,6 +90,24 @@ 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag |
|
|
|
|
def get_customer_chat_open_projects(user): |
|
|
|
|
team_ids = [] |
|
|
|
|
if user.is_owner_team(): |
|
|
|
|
team_ids.append(user.team.pk) |
|
|
|
|
count = Order.objects.filter(Q(contractor=user) | Q(team_id__in=team_ids)).count() |
|
|
|
|
return count |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.filter |
|
|
|
|
def get_project_message_count(user): |
|
|
|
|
if user.is_customer(): |
|
|
|
|
|