From e5827d634702a2aa1c896295ee25b82ecf4da547 Mon Sep 17 00:00:00 2001
From: Mukhtar
Date: Mon, 12 Sep 2016 13:33:28 +0300
Subject: [PATCH] #ARC-26 Fixes signals
---
assets/js/chat.js | 14 ++++++++++++--
assets/js/chat_contractor.js | 7 +------
chat/chat.py | 8 ++++----
chat/templates/chat_contractor.html | 28 ++++++++++++++--------------
templates/partials/base.html | 2 +-
users/templatetags/user_tags.py | 3 ++-
wallets/signals.py | 2 +-
wallets/views.py | 4 ----
8 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/assets/js/chat.js b/assets/js/chat.js
index 10977ed..2f360c7 100644
--- a/assets/js/chat.js
+++ b/assets/js/chat.js
@@ -1,6 +1,6 @@
var SocketHandler = function () {
domain = domain.replace(':' + port, '');
- var url = 'ws://' + domain + ':8888/chat/' + userId + '/';
+ var url = 'ws://' + domain + '/chat/' + userId + '/';
var sock = new WebSocket(url);
var intervalId;
sock.onopen = function () {
@@ -92,7 +92,6 @@ $(function () {
});
}
-
var currentHash = URI(location.href).hash();
if (currentHash.indexOf("#order") == 0) {
var ordHashId = currentHash.replace("#order", "");
@@ -124,6 +123,17 @@ $(function () {
$(".order-block").first().trigger('click');
location.hash = '';
}, 500);
+
+ setTimeout(function () {
+ var firstTeamBlock = $(".team-block").first();
+ var firstTeamOrder = $(".team-order-block").first();
+ if (firstTeamOrder.length == 1){
+ firstTeamOrder.trigger('click');
+ } else if(firstTeamBlock.length == 1){
+ firstTeamBlock.trigger('click');
+ }
+ location.hash = '';
+ }, 1000);
}
// Информация о заказе
$(".full-order-info").click('on', function (e) {
diff --git a/assets/js/chat_contractor.js b/assets/js/chat_contractor.js
index 4602b75..207f06f 100644
--- a/assets/js/chat_contractor.js
+++ b/assets/js/chat_contractor.js
@@ -1,8 +1,5 @@
$(function () {
var form = document.getElementById('message_form');
- setTimeout(function () {
- $(".team-order-block").first().trigger('click');
- }, 1000);
var url = '/chat/create/';
@@ -135,7 +132,6 @@ $(function () {
});
$(".team-order-block").on('click', function () {
-
$('.team-order-block, .team-block').each(function () {
$(this).removeClass('orAct');
});
@@ -150,7 +146,6 @@ $(function () {
$("#add-form-team-note #teamNote").val(teamId);
$("#add-form-team-note #orderNote").val(orderId);
-
var inbox = document.getElementById('message-chat-team-space');
inbox.innerHTML = '';
var docList = document.getElementById('documentTeamSpace');
@@ -218,6 +213,7 @@ $(function () {
});
$('.team-block').on('click', function () {
+
$('.team-order-block, .team-block').each(function () {
$(this).removeClass('orAct');
});
@@ -502,7 +498,6 @@ $(function () {
});
-
$('#tab2').on('click', '.closeStage', function (e) {
e.preventDefault();
var stageId = $(this).attr('data-stage-id');
diff --git a/chat/chat.py b/chat/chat.py
index 4b79f5d..8eb0ca9 100644
--- a/chat/chat.py
+++ b/chat/chat.py
@@ -56,9 +56,8 @@ class ChatHandler(websocket.WebSocketHandler):
def add_message(self, message_data):
sender_id = message_data['data']['sender_id']
- recipent_id = message_data['data']['recipent_id']
+ recipent_id = message_data['data'].get('recipent_id', None)
order_id = message_data['data'].get('order_id', None)
-
team_id = message_data['data'].get('team_id', None)
message = message_data['data'].get('chat_message', None)
docs_send_links = message_data['data'].get('document_send_links', None)
@@ -77,8 +76,9 @@ class ChatHandler(websocket.WebSocketHandler):
is_new = 'true'
is_delete = 'false'
- team_value = "NULL" if team_id is None else team_id
- if team_value and not recipent_id:
+ team_value = "NULL" if team_id is None or not team_id else team_id
+
+ if not team_id and not recipent_id:
recipent_id = sender_id
order_value = "NULL" if order_id is None or not order_id else order_id
diff --git a/chat/templates/chat_contractor.html b/chat/templates/chat_contractor.html
index 3084f02..9d052e2 100644
--- a/chat/templates/chat_contractor.html
+++ b/chat/templates/chat_contractor.html
@@ -254,12 +254,12 @@
Чаты:
{% if request.user.pk != torder.team.owner.pk %}
{{ torder.team.owner.username }},
+ data-id="{{ torder.team.owner.pk}}">{{ torder.team.owner.username }}
{% endif %}
{% for tuser in torder.team.contractors.all %}
{% if request.user.pk != tuser.pk %}
{{ tuser.username }},
+ data-id="{{ tuser.pk }}">{{ tuser.username }}
{% endif %}
{% endfor %}
@@ -289,10 +289,12 @@
Чаты:
{% if request.user.pk != torder.team.owner.pk %}
- {{ yteam.owner.username }},
+ {{ yteam.owner.username }}
+ {% endif %}
+ {% for tuser in yteam.contractors.all %}
+ {% if request.user.pk != tuser.pk %}
+ {{ tuser.username }}
{% endif %}
- {% for tuser in yteam.contractors.all %}{{ tuser.username }},
-
{% endfor %}
@@ -305,15 +307,15 @@
diff --git a/templates/partials/base.html b/templates/partials/base.html
index 4ef3798..8ed6bd6 100644
--- a/templates/partials/base.html
+++ b/templates/partials/base.html
@@ -87,7 +87,7 @@
if ((queryString.indexOf('/chat') != 0) && (queryString.indexOf('/users/contractor-office/510/work-projects') != 0)) {
domain = domain.replace(':' + port, '');
- var url = 'ws://' + domain + ':8888/chat/' + userId + '/';
+ var url = 'ws://' + domain + '/chat/' + userId + '/';
var sock = new WebSocket(url);
var intervalId;
sock.onopen = function () {
diff --git a/users/templatetags/user_tags.py b/users/templatetags/user_tags.py
index 4762717..6a90054 100644
--- a/users/templatetags/user_tags.py
+++ b/users/templatetags/user_tags.py
@@ -30,7 +30,8 @@ def has_group(user, group_name):
@register.inclusion_tag('templatetags/user_new_count.html', takes_context=True)
def count_new_message(context, user):
- new_count = 3
+ from chat.models import Message
+ new_count = Message.objects.filter(is_delete=False, is_new=True, recipent=user).count()
return {
'new_count': new_count,
}
diff --git a/wallets/signals.py b/wallets/signals.py
index b570ee7..42b6cfd 100644
--- a/wallets/signals.py
+++ b/wallets/signals.py
@@ -73,7 +73,7 @@ def reserve_stages(sender, instance, created, **kwargs):
@receiver(post_save, sender=PayFromScore)
-def reserve_stages(sender, instance, created, **kwargs):
+def reserve_stages_from_score(sender, instance, created, **kwargs):
order = None
stages_names = []
stages_ids_raw = instance.stages_id
diff --git a/wallets/views.py b/wallets/views.py
index 37baf39..46856bb 100644
--- a/wallets/views.py
+++ b/wallets/views.py
@@ -98,10 +98,6 @@ class AjaxableResponseMixin(object):
return response
-# class WithDrawCreate(AjaxableResponseMixin, CreateView):
-# model = WithDraw
-# form_class = WithDrawForm
-# success_url = '/'
class WithDrawCreate(CreateView):
model = WithDraw