';
+ }
+ if (data.secure) {
+ stageWork += '
';
+ }
+ $("#stagesWork").html(stageWork);
+ } else {
+ $("#completeWork").hide();
+ }
+
+ if (stagesCompleted.length == stagesResults.length && stagesCompleted.length > 0) {
+ $("#leaveReview").show();
+ }
+
+ if (data.status == 'completed') {
+ $("#leaveReview").hide();
+ }
+ });
+
+
+ });
+
+
+ $('#tab2').on('click', '.closeStage', function (e) {
+ e.preventDefault();
+ var stageId = $(this).attr('data-stage-id');
+ var _this = $(this);
+ $.ajax({
+ url: '/api/stages/' + stageId + '/',
+ type: 'PATCH',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'))
+ },
+ data: "close_contractor=True",
+ dataType: 'json',
+ success: function (json) {
+
+ socket.send_stages_approve({
+ "format_type": "approve_stages",
+ "data": {
+ "sender_id": _this.attr('data-sender-id'),
+ "recipent_id": _this.attr('data-recipent-id'),
+ "order_id": _this.attr('data-order-id'),
+ "msg": "Исполнитель завершил этап " + json.name,
+ }
+ });
+
+ console.log(json);
+ },
+ error: function (e) {
+ console.log('error');
+ console.log(e);
+ }
+ });
+ });
+
+ //Добавить сообщение для исполнителей в группе
+ $("#add-team-chat-message").on('click', function (e) {
+ e.preventDefault();
+ var chatMessage = $("#team-chat-form #chatText").val();
+ var recipentId = $("#team-chat-form #recipentTeamId").val();
+ var senderId = $("#team-chat-form #senderTeamId").val();
+ var teamId = $("#team-chat-form #teamId").val();
+ var orderId = $("#team-chat-form #orderTeamId").val();
+ var documentSendIds = $("#documentSendIds").val();
+
+ if (chatMessage) {
+ var sendLinks = $("#document-send a");
+ var sendLinkIds = "";
+ $.each(sendLinks, function (i, v) {
+ sendLinkIds += $(this).attr('data-id') + ';';
+ });
+ socket.add_team_message({
+ "format_type": "add_message_team",
+ "data": {
+ "sender_id": senderId,
+ "recipent_id": recipentId,
+ "chat_message": chatMessage,
+ "team_id": teamId,
+ "order_id": orderId,
+ "document_send_links": sendLinkIds,
+ }
+ });
+
+ $("#team-chat-form #chatText").val("");
+ $("#document-send").html("");
+ $("#documentSendIds").val("");
+ }
+ });
+
+});
diff --git a/chat/migrations/0012_notes_team.py b/chat/migrations/0012_notes_team.py
new file mode 100644
index 0000000..64e3b57
--- /dev/null
+++ b/chat/migrations/0012_notes_team.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-09-07 08:01
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0015_user_phone2'),
+ ('chat', '0011_documents_is_delete'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='notes',
+ name='team',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='users.Team'),
+ ),
+ ]
diff --git a/chat/migrations/0013_auto_20160907_1556.py b/chat/migrations/0013_auto_20160907_1556.py
new file mode 100644
index 0000000..2a9e815
--- /dev/null
+++ b/chat/migrations/0013_auto_20160907_1556.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-09-07 12:56
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('chat', '0012_notes_team'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='notes',
+ name='recipent',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='recipent_notes', to=settings.AUTH_USER_MODEL),
+ ),
+ ]
diff --git a/chat/models.py b/chat/models.py
index f372c27..88b30a0 100644
--- a/chat/models.py
+++ b/chat/models.py
@@ -28,8 +28,9 @@ class Notes(models.Model):
text = models.TextField()
created = models.DateTimeField(default=timezone.now)
sender = models.ForeignKey(User, related_name='sender_notes')
- recipent = models.ForeignKey(User, related_name='recipent_notes')
+ recipent = models.ForeignKey(User, related_name='recipent_notes', null=True, blank=True)
order = models.ForeignKey(Order, related_name='notes', null=True, blank=True)
+ team = models.ForeignKey(Team, related_name='notes', null=True, blank=True)
def __str__(self):
return self.text
diff --git a/chat/serializers.py b/chat/serializers.py
index 765bfd5..74da60e 100644
--- a/chat/serializers.py
+++ b/chat/serializers.py
@@ -62,8 +62,8 @@ class MessageSerializer(ModelSerializer):
out = obj.text
documents = obj.documents.all()
if len(documents)>0:
- documents_str = '
'.join(['
' + doc.file.name + '' for doc in documents])
- out += '
' + documents_str
+ documents_str = '
'.join(['Входящий файл:
' + doc.file.name + '' for doc in documents])
+ out += '
' + documents_str
return out
@@ -78,4 +78,5 @@ class NoteSerializer(ModelSerializer):
'order',
'sender',
'recipent',
+ 'team',
)
diff --git a/chat/templates/chat_contractor.html b/chat/templates/chat_contractor.html
index c33dc32..a644ad9 100644
--- a/chat/templates/chat_contractor.html
+++ b/chat/templates/chat_contractor.html
@@ -55,7 +55,7 @@
-
Контакты
+
Контакты
0
@@ -213,14 +213,14 @@