+ id="orderBlock{{ order.id }}"
+ data-team-id="{% if order.team %}{{ order.team.pk }}{% else %}0{% endif %}"
+ data-recipent-id="{{ order.project.customer.pk }}" data-id="{{ order.id }}">
-
-
-
Заказы
- {% for torder in team_orders %}
-
-
-
- {{ torder }}
+
+
+
+
+
Заказы
+ {% for torder in team_orders %}
+
+
+
+ {{ torder }}
+
+
+
+
+ {% get_new_count_for_team request.user torder.team.id torder.pk %}
+ Исполнитель: {{ torder.team.name }}
-
-
-
- {% get_new_count_for_team request.user torder.team.id torder.pk %}
- Исполнитель: {{ torder.team.name }}
-
-
- {% for tuser in torder.team.users.all %}
- - {{ tuser }}
- {% endfor %}
-
-
- Чаты:
- {% if request.user.pk != torder.team.owner.pk %}
- {{ torder.team.owner.username }}
- {% endif %}
- {% for tuser in torder.team.contractors.all %}
- {% if request.user.pk != tuser.pk %}
- {{ tuser.username }}
- {% endif %}
- {% endfor %}
-
-
-
- Полное описание заказа
-
-
+
+ {% for tuser in torder.team.users.all %}
+ - {{ tuser }}
+ {% endfor %}
+
+
+ Чаты:
+ {% if request.user.pk != torder.team.owner.pk %}
+ {{ torder.team.owner.username }}
+ {% endif %}
+ {% for tuser in torder.team.contractors.all %}
+ {% if request.user.pk != tuser.pk %}
+ {{ tuser.username }}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Полное описание заказа
+
- {% endfor %}
+
+ {% endfor %}
- {% for yteam in your_teams %}
-
-
-
- {{ yteam }}
+ {% for yteam in your_teams %}
+
+
+
+ {{ yteam }}
+
+
+
+ {% get_new_count_for_team request.user yteam.id %}
+ Владелец группы: {{ yteam.owner }}
+
+
+ {% for tuser in yteam.contractors.all %}
+ - {{ tuser }}
+ {% endfor %}
+
+
+ Чаты:
+ {% if request.user.pk != torder.team.owner.pk %}
+ {{ yteam.owner.username }}
+ {% endif %}
+ {% for tuser in yteam.contractors.all %}
+ {% if request.user.pk != tuser.pk %}
+ {{ tuser.username }}
+ {% endif %}
+ {% endfor %}
-
-
- {% get_new_count_for_team request.user yteam.id %}
- Владелец группы: {{ yteam.owner }}
-
-
- {% for tuser in yteam.contractors.all %}
- - {{ tuser }}
- {% endfor %}
-
-
- Чаты:
- {% if request.user.pk != torder.team.owner.pk %}
- {{ yteam.owner.username }}
- {% endif %}
- {% for tuser in yteam.contractors.all %}
- {% if request.user.pk != tuser.pk %}
- {{ tuser.username }}
- {% endif %}
- {% endfor %}
-
-
+
- {% endfor %}
-
+ {% endfor %}
-
-
-
- {% include 'order_info.html' %}
-
+
+
+
+ {% include 'order_info.html' %}
+
{% include 'partials/footer.html' %}
@@ -414,12 +409,12 @@
{% endblock %}
{% block js_block %}
-
-
-
+
+
{% endblock %}
diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html
index 9755e5a..0f65f65 100644
--- a/chat/templates/chat_customer.html
+++ b/chat/templates/chat_customer.html
@@ -35,35 +35,7 @@
Контакты
{% for contact in contacts_users %}
-
+ {% include 'inc-contact-card.html' %}
{% endfor %}
@@ -127,7 +99,8 @@
Заказы
{% for order in orders %}
{{ order }}
- {% get_new_count_for_order request.user order.order.id %}
+ {% get_new_count_for_order request.user order.order.id %}
Исполнитель:
{% if order.order.contractor %}
{{ order.order.contractor.get_full_name }}
@@ -152,9 +126,9 @@
Полное описание заказа
-{# #}
-{# Удалить заказ#}
-{# #}
+ {# #}
+ {# Удалить заказ#}
+ {# #}
@@ -164,17 +138,17 @@
{% if archive_projects %}
Архивные заказы
-
- {% for proj in archive_projects %}
-
-
-
{{ proj.name }}
-
+
+ {% for proj in archive_projects %}
+
-
- {% endfor %}
-
+ {% endfor %}
+
{% endif %}
diff --git a/chat/templates/inc-contact-card.html b/chat/templates/inc-contact-card.html
new file mode 100644
index 0000000..fc3abbe
--- /dev/null
+++ b/chat/templates/inc-contact-card.html
@@ -0,0 +1,56 @@
+{% load thumbnail %}
+{% load static %}
+{% load user_tags %}
+
+
\ No newline at end of file
diff --git a/common/templatetags/__init__.py b/common/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/common/templatetags/common_tags.py b/common/templatetags/common_tags.py
index 28e7f56..add294a 100644
--- a/common/templatetags/common_tags.py
+++ b/common/templatetags/common_tags.py
@@ -148,4 +148,10 @@ def get(dic, key):
return dic.get(key)
+@register.filter
+def max_count(value, max_value):
+ if value > max_value:
+ return '99+'
+ return str(value)
+
# import code; code.interact(local=dict(globals(), **locals()))
diff --git a/context_processors/user_info.py b/context_processors/user_info.py
new file mode 100644
index 0000000..089fb6a
--- /dev/null
+++ b/context_processors/user_info.py
@@ -0,0 +1,26 @@
+# from django.core.context_processors import request
+from django.db.models import Sum
+from wallets.models import InvoiceHistory
+from chat.models import NewMessage
+from projects.models import Order
+
+
+def user_info(request):
+ if request.user.is_authenticated():
+ current_sum_info = InvoiceHistory.objects.filter(user=request.user, type="score").aggregate(Sum('sum'))
+ user_balance = current_sum_info['sum__sum'] or 0
+
+ new_messages_count = NewMessage.objects.filter(user=request.user).count()
+ num_orders_in_work = request.user.orders.filter(status='process').count()
+ try:
+ fist_order_id = request.user.orders.all()[0].id
+ except IndexError:
+ fist_order_id = ""
+ return {
+ "user_balance": user_balance,
+ "new_messages_count": new_messages_count,
+ "num_orders_in_work": num_orders_in_work,
+ "fist_order_id": fist_order_id
+ }
+
+ return {}
diff --git a/projects/signals.py b/projects/signals.py
index f03f9bc..6a68700 100644
--- a/projects/signals.py
+++ b/projects/signals.py
@@ -2,7 +2,7 @@ from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
-from .models import Stage
+from .models import Stage, Order
@receiver(post_save, sender=Stage)
diff --git a/projects/views.py b/projects/views.py
index 626eaa0..3ba92be 100644
--- a/projects/views.py
+++ b/projects/views.py
@@ -116,6 +116,7 @@ class ProjectDetailWithAnswerView(BaseMixin, View):
return render(request, self.template_name, context)
def post(self, request, *args, **kwargs):
+ # @Отклик на Проект(Project)
if request.user.is_authenticated() and request.user.is_contractor():
context = self.get_context_data(**kwargs)
answer_as_team = None
@@ -138,6 +139,7 @@ class ProjectDetailWithAnswerView(BaseMixin, View):
else:
form = self.form_class(request.POST, request=request, project=project)
+ # FIXME: еще раз находим проект?
project = get_object_or_404(Project, pk=kwargs.get('pk'))
context.update({'project': project})
@@ -521,13 +523,15 @@ class CustomerProjectCreateView(BaseMixin, View):
def post(self, request, *args, **kwargs):
form = self.form_class(request.POST, request=request) # Passing `request.FILES` seems unnecessary here. Files are added manually below
- # print('POST = ', request.POST)
+ print('POST = ', request.POST)
form.is_valid()
realty = form.cleaned_data.get('realty')
if realty:
+ print("Has Realty")
realty_form = self.realty_form(request.POST, instance=realty, request=request, prefix='realty_form')
else:
+ print("Create new Realty")
realty_form = self.realty_form(request.POST, request=request, prefix='realty_form')
if form.is_valid() and realty_form.is_valid():
@@ -546,13 +550,13 @@ class CustomerProjectCreateView(BaseMixin, View):
for file in request.FILES.getlist('new_files'):
ProjectFile.objects.create(file=file, project=project)
- if realty:
- realty_form.save()
- else:
+ if not realty:
realty = realty_form.save(commit=False)
realty.user = user
if not request.POST.get('new_realty_name'):
+ print("Virtual!")
realty.is_virtual = True
+ print("Set realty name -->", request.POST.get('new_realty_name'))
realty.name = request.POST.get('new_realty_name')
realty.save()
realty_form.save_m2m()
@@ -848,6 +852,7 @@ class CustomerOfferOrderView(View):
template_name = 'chattest.html'
def post(self, request, *args, **kwargs):
+ # @ Утверждение Исполнителя
project_id = kwargs.get('project_id')
answer_id = kwargs.get('answer_id')
try:
@@ -864,12 +869,14 @@ class CustomerOfferOrderView(View):
if not order.contractor and not order.team:
if isinstance(answer.author, User):
order.contractor = answer.author
- order.save()
- status = True
+ # order.status = 'process'
+ # order.save()
+ # status = True
elif isinstance(answer.author, Team):
order.team = answer.author
- order.save()
- status = True
+ order.status = 'process'
+ order.save()
+ status = True
if status:
hs_rating = HistoryRating()
hs_rating.user = request.user
diff --git a/reviews/signals.py b/reviews/signals.py
index e47f225..ce50ce9 100644
--- a/reviews/signals.py
+++ b/reviews/signals.py
@@ -23,6 +23,7 @@ def add_rating_review(sender, instance, created, **kwargs):
hs_rating.save()
count_reviews = Review.objects.filter(project=instance.project).count()
+ print("count_reviews = ", count_reviews)
if count_reviews == 2:
order = instance.project.order
order.status = 'completed'
diff --git a/templates/home.html b/templates/home.html
index 20ae8e4..da35f42 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -140,6 +140,7 @@
{% endblock %}
{% block js_block %}
+ {{ block.super }}
{% endblock %}
diff --git a/templates/partials/base.html b/templates/partials/base.html
index 0f7d67e..2e2060d 100644
--- a/templates/partials/base.html
+++ b/templates/partials/base.html
@@ -14,7 +14,6 @@
{# {% compress css %}#}
{% block old_css %}
-
@@ -22,13 +21,14 @@
-
{% endblock %}
{% block common_css %}
+
+
{% endblock %}
{% block head_css %}
@@ -76,7 +76,7 @@
{% block common_js %}
-{# #}
+ {# #}
{% endblock %}
{#{% compress js %}#}
{% block old_js %}
@@ -98,21 +98,44 @@
-
+
+{% endblock %}
+
+{% block ws_block %}
+
{% endblock %}
diff --git a/templates/partials/header.html b/templates/partials/header.html
index 6bbe587..cea82c3 100644
--- a/templates/partials/header.html
+++ b/templates/partials/header.html
@@ -3,11 +3,12 @@
{% load user_tags %}
{% load activeurl %}
{% load sass_tags %}
+{% load common_tags %}
{% if request.user.is_contractor %}
- {% url 'users:contractor-profile' pk=request.user.pk as profile_url %}
+ {% url 'users:contractor-profile' pk=request.user.pk as profile_url %}
{% elif request.user.is_customer %}
- {% url 'users:customer-profile-open-projects' pk=request.user.pk as profile_url %}
+ {% url 'users:customer-profile-open-projects' pk=request.user.pk as profile_url %}
{% endif %}
@@ -15,19 +16,22 @@
-
-
+
-
+
{% activeurl %}
- {% if request.user.is_authenticated %}
-
+
- {% else %}
-
- {% endif %}
- {% endactiveurl %}
-
- {% if request.user.is_authenticated %}
-
+ {% endif %}
+
+ {% endactiveurl %}
+
+ {% if request.user.is_authenticated %}
{% if request.user.is_contractor %}
{% contractor_indicator request.user %}
{% endif %}
@@ -84,30 +90,31 @@
@@ -150,14 +162,25 @@
{% endif %}
+ {% if request.user.is_contractor %}
+
+ {% endif %}
-
- {% else %}
-
- {% endif %}
+
+
+
+ {% endif %}
+
diff --git a/templates/partials/sass/header.sass b/templates/partials/sass/header.sass
index 2b3e2f2..bba0857 100644
--- a/templates/partials/sass/header.sass
+++ b/templates/partials/sass/header.sass
@@ -7,14 +7,61 @@
.topMain
width: 1200px
margin: 0 auto
+ color: #ffffff
+ .dropdown-menu > li > a
+ display: inline-block
.col-lg-7
width: 55%
.col-lg-2
width: 19%
.mainMenu li
+ cursor: pointer
padding-right: 25px
a
font-size: 15px
+ //&:hover
+ cursor: pointer
+
+ .user-info
+ float: right
+ height: 100%
+ a
+ display: block
+ color: white
+ cursor: pointer
+ &:hover
+ text-decoration: none
+ color: #FF0029
+ .cash
+ text-align: right
+ padding-top: 4px
+ .icon_hand
+ padding-left: 26px
+ background:
+ image: url("#{$static}/img/icons/icon_hands.png")
+ size: 24px 24px
+ repeat: no-repeat
+ &:hover
+ background-image: url("#{$static}/img/icons/icon_hands_red.png")
+ .icon_chat
+ margin-top: 4px
+ padding-left: 26px
+ background:
+ image: url("#{$static}/img/icons/icon_speach-ball.png")
+ size: 18px 18px
+ repeat: no-repeat
+ &:hover
+ background-image: url("#{$static}/img/icons/icon_speach-ball_red.png")
+
+.circle
+ background-color: red
+ border-radius: 50%
+ width: 30px
+ height: 30px
+ line-height: 30px
+ display: inline-block
+ text-align: center
+ //align-items: center
.welcomeMain
width: 100%
@@ -41,6 +88,7 @@
.mainMenu
float: left
margin: 26px 0 0 0
+ padding-left: 60px
li
float: left
position: relative
@@ -161,14 +209,16 @@
&.icon_tm3.active span
background: url('#{$static}/img/listMain2.png') no-repeat right !important
-li.officeList.icon_tml > a > p
+li.officeList.icon_tml > a > .count
display: inline-block
- padding: 5px 7px 3px 7px
- background: #ff0000
- border-radius: 35px
- position: absolute
- right: -34px
- top: -4px
+ color: red
+ font-family: 'pfbeausanspro-reg', sans-serif
+ //padding: 5px 7px 3px 7px
+ background: none
+ border-radius: 0
+ position: inherit
+ //right: -34px
+ //top: -4px
.reg, .reg:link, .reg:visited
color: #fb1818
@@ -191,7 +241,8 @@ li.officeList.icon_tml > a > p
width: 75px
height: 75px
float: right
- margin: 0 0 0 -60px
+ margin: 0
+ padding-left: 5px
img
display: block
width: 100%
@@ -282,6 +333,13 @@ li.officeList.icon_tml > a > p
height: 20px
background-size: contain
background: url('#{$static}/img/user-5.png') no-repeat 0 0
+ .icon_chat a span
+ height: 20px
+ background:
+ image: url("#{$static}/img/icons/icon_speach-ball.png")
+ size: contain
+ repeat: no-repeat
+
.icon_mm1 a:hover span
height: 20px
background: url('#{$static}/img/menu2.png') no-repeat center !important
@@ -315,3 +373,9 @@ li.officeList.icon_tml > a > p
height: 20px
background-size: contain
background: url('#{$static}/img/user-4.png') no-repeat 0 0
+ .icon_chat a:hover span
+ height: 20px
+ background:
+ image: url("#{$static}/img/icons/icon_speach-ball_red.png")
+ size: contain
+ repeat: no-repeat
\ No newline at end of file
diff --git a/users/templates/templatetags/user_new_count.html b/users/templates/templatetags/user_new_count.html
index 3c89bb0..c6a5d63 100644
--- a/users/templates/templatetags/user_new_count.html
+++ b/users/templates/templatetags/user_new_count.html
@@ -1 +1 @@
-
{{ new_count }}
+
{{ new_count }}
diff --git a/users/templates/templatetags/user_new_count_orders.html b/users/templates/templatetags/user_new_count_orders.html
index 8b9b759..a34c0bb 100644
--- a/users/templates/templatetags/user_new_count_orders.html
+++ b/users/templates/templatetags/user_new_count_orders.html
@@ -1 +1 @@
-
{{ new_count }}
+
{{ new_count }}
diff --git a/users/templatetags/user_tags.py b/users/templatetags/user_tags.py
index 48753b3..55e312b 100644
--- a/users/templatetags/user_tags.py
+++ b/users/templatetags/user_tags.py
@@ -10,7 +10,6 @@ from projects.models import Order
from reviews.models import Review
from users.helpers import get_projects_grouped
-
register = template.Library()
@@ -50,7 +49,13 @@ def count_new_message(context, user):
@register.inclusion_tag('templatetags/user_new_count_orders.html', takes_context=True)
def count_new_message_orders(context, user):
- new_count = NewMessage.objects.filter(user=user, message__order__in=user.orders.all(),
+ """
+
+ :param context:
+ :param user:
+ :return:
+ """
+ new_count = NewMessage.objects.filter(user=user, message__order__in=user.orders.filter(status='created'),
message__team__isnull=True).count()
try:
team = user.team
@@ -58,23 +63,30 @@ def count_new_message_orders(context, user):
team = None
if team:
- new_count_team = NewMessage.objects.filter(user=user, message__order__in=user.team.orders.all(),
+ new_count_team = NewMessage.objects.filter(user=user,
+ message__order__in=user.team.orders.filter(status='created'),
message__team__isnull=True).count()
new_count += new_count_team
+
+ if new_count > 99:
+ new_count = '99+'
return {
'new_count': new_count,
}
@register.simple_tag
-def get_new_count_message(team_pk,user=None):
+def get_new_count_message(team_pk, user=None):
count = NewMessage.objects.filter(user=user, message__team=team_pk, message__order__isnull=True).count()
return count
@register.simple_tag
def get_new_count_for_contact(contact, current_user):
- count = current_user.new_messages.filter(message__sender=contact, message__order__isnull=True, message__team__isnull=True).count()
+ count = current_user.new_messages.filter(message__sender=contact, message__order__isnull=True,
+ message__team__isnull=True).count()
+ if count > 99:
+ new_count = '99+'
return count
@@ -114,14 +126,17 @@ def get_customer_chat_open_projects(user):
@register.filter
def get_project_message_count(user):
if user.is_customer():
- projects = user.customer_projects.filter(state='active').exclude(order__contractor__isnull=True, order__team__isnull=True)
+ projects = user.customer_projects.filter(state='active').exclude(order__contractor__isnull=True,
+ order__team__isnull=True)
return projects.aggregate(c=Count('answers__messages'))['c']
elif user.is_contractor():
- message_count = user.contractor_answers.filter(project__state='active', rejected=False).aggregate(c=Count('messages'))['c']
-
+ message_count = \
+ user.contractor_answers.filter(project__state='active', rejected=False).aggregate(c=Count('messages'))['c']
+
if util.has_related(user, 'team'):
- message_count += user.team.answers.filter(project__state='active', rejected=False).aggregate(c=Count('messages'))['c']
-
+ message_count += \
+ user.team.answers.filter(project__state='active', rejected=False).aggregate(c=Count('messages'))['c']
+
return message_count
diff --git a/wallets/models.py b/wallets/models.py
index 1ef97fd..69f1529 100644
--- a/wallets/models.py
+++ b/wallets/models.py
@@ -41,7 +41,7 @@ class InvoiceHistory(models.Model):
current_sum_info = InvoiceHistory.objects.filter(user=self.user, type="score").aggregate(Sum('sum'))
current_sum = current_sum_info['sum__sum'] or 0
if self.type == "score":
- self.balance = current_sum + self.sum
+ self.balavoids_atnce = current_sum + self.sum
else:
self.balance = current_sum
super().save(*args, **kwargs)
diff --git a/wallets/views.py b/wallets/views.py
index 1cc245c..6170574 100644
--- a/wallets/views.py
+++ b/wallets/views.py
@@ -76,15 +76,15 @@ class ScoreView(LoginRequiredMixin, View):
template_name = 'score-detail.html'
def get(self, request, *args, **kwargs):
- # transaction = Transaction.objects.get_or_create(customer=request.user, complete=False)
- transaction = Transaction.objects.get_or_create(customer=request.user, type='add', complete=False)
+ transaction, created = Transaction.objects.get_or_create(customer=request.user, type='add', complete=False)
+ # transaction = Transaction.objects.filter(customer=request.user, type='add', complete=False)
user_score = get_object_or_404(User.objects, pk=kwargs.get('pk'))
current_sum_info = InvoiceHistory.objects.filter(user=user_score, type="score").aggregate(Sum('sum'))
user_score_balance = current_sum_info['sum__sum'] or 0
form = WithDrawForm
return render(request, self.template_name, {
- 'transaction': transaction[0],
+ 'transaction': transaction,
'YANDEX_MONEY': settings.YANDEX_MONEY,
'user_score': user_score,
'user_score_balance': user_score_balance,