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 @@