From fbac71997e669cd1f14b0c74c415b3b73403780c Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Mon, 29 Aug 2016 19:41:42 +0300 Subject: [PATCH 1/2] #ARC-16 Filter messages for orders --- api/views.py | 5 +- assets/css/extra.css | 4 + assets/js/chat.js | 263 +++++++++++++----- chat/chat.py | 2 +- chat/filters.py | 1 + chat/serializers.py | 1 + chat/templates/chat_contractor.html | 111 ++------ chat/templates/chat_customer.html | 121 +++----- chat/views.py | 18 +- .../migrations/0018_auto_20160829_1751.py | 20 ++ projects/migrations/0019_remove_stage_term.py | 19 ++ projects/migrations/0020_stage_term.py | 23 ++ projects/models.py | 2 +- projects/serializers.py | 14 +- projects/templates/comparison.html | 9 +- projects/templates/project_detail.html | 6 +- projects/views.py | 6 +- templates/partials/base.html | 10 +- .../migrations/0007_auto_20160829_1740.py | 20 ++ 19 files changed, 379 insertions(+), 276 deletions(-) create mode 100644 projects/migrations/0018_auto_20160829_1751.py create mode 100644 projects/migrations/0019_remove_stage_term.py create mode 100644 projects/migrations/0020_stage_term.py create mode 100644 work_sell/migrations/0007_auto_20160829_1740.py diff --git a/api/views.py b/api/views.py index 4ebd8d6..49b0ff2 100755 --- a/api/views.py +++ b/api/views.py @@ -72,7 +72,7 @@ class DocumentViewSet(ModelViewSet): if search_param: # import code; code.interact(local=dict(globals(), **locals())) if search_param == 'in': - queryset = queryset.filter(Q(sender__in=[sender_id,recipent_id]),Q(recipent__in=[sender_id,recipent_id])).order_by('created') + queryset = queryset.filter(Q(sender__in=[sender_id, recipent_id]),Q(recipent__in=[sender_id, recipent_id])).filter(order__isnull=True).order_by('created') return queryset @@ -99,6 +99,7 @@ class NoteViewSet(ModelViewSet): queryset = queryset.filter(Q(sender__in=[sender_id,recipent_id]),Q(recipent__in=[sender_id,recipent_id])).order_by('created') return queryset + class MessageViewSet(ModelViewSet): queryset = Message.objects.all() serializer_class = MessageSerializer @@ -112,7 +113,7 @@ class MessageViewSet(ModelViewSet): if search_param: # import code; code.interact(local=dict(globals(), **locals())) if search_param == 'in': - queryset = queryset.filter(Q(sender__in=[sender_id,recipent_id]),Q(recipent__in=[sender_id,recipent_id])).order_by('created') + queryset = queryset.filter(Q(sender__in=[sender_id,recipent_id]),Q(recipent__in=[sender_id,recipent_id])).filter(order__isnull=True).order_by('created') return queryset diff --git a/assets/css/extra.css b/assets/css/extra.css index 3b50ed2..de2c7f4 100644 --- a/assets/css/extra.css +++ b/assets/css/extra.css @@ -107,3 +107,7 @@ font-size: 15px; } + +#jGrowl .jGrowl-notification a, #jGrowl .jGrowl-notification a:visited { + color: #777620; +} diff --git a/assets/js/chat.js b/assets/js/chat.js index 047012e..0b28601 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -14,7 +14,13 @@ var SocketHandler = function () { var message = JSON.parse(event.data); var inbox; if (message.answer_type == 'contact' || message.answer_type == 'add_message_contact') { - inbox = document.getElementById('message-chat-space'); + var sumSenderRecipent = parseInt(message.recipent_id) + parseInt(message.sender_id); + var inboxClass = document.getElementsByClassName('contact-space' + sumSenderRecipent); + if (inboxClass.length > 0) { + inbox = inboxClass[0]; + }else{ + $(".contact-count-" + sumSenderRecipent).text(parseInt($(".contact-count-" + sumSenderRecipent).text()) + 1); + } } else if (message.answer_type == 'order' || message.answer_type == 'add_message_order') { inbox = document.getElementById('message-chat-order-space'); } else if (message.answer_type == 'add_message_team') { @@ -123,6 +129,99 @@ $(function () { } + // Вытащить сообщения для конактов + + $('.user-block').on('click', function () { + var contactId = $(this).attr('data-id'); + $("#contact-chat-form #recipentContactId").val(contactId); + $("#add-form-contractor-note #recipentNoteContractor").val(contactId); + + $('.user-block').each(function () { + $(this).removeClass('mesAct'); + }); + + $(this).addClass('mesAct'); + var inbox = document.getElementById('message-chat-space'); + var sumSenderRecipent = parseInt(userId) + parseInt(contactId); + + $("#message-chat-space").removeClass().addClass("contact-space" + sumSenderRecipent); + $(".contact-count-"+ sumSenderRecipent).text(0); + var docList = document.getElementById('documentSpace'); + inbox.innerHTML = ''; + docList.innerHTML = ''; + + $.ajax({ + url: '/api/documents', + type: 'GET', + data: { + csrfmiddlewaretoken: csrftoken, + 'operand': 'in', + 'sender_id': userId, + 'recipent_id': contactId, + }, + dataType: 'json', + + success: function (json) { + console.log(json); + + $.each(json.results, function (i, v) { + docList.innerHTML += '
  • ' + v.file + '
  • '; + }); + }, + error: function (e) { + console.log(e); + } + }); + + $.ajax({ + url: '/api/message', + type: 'GET', + data: { + csrfmiddlewaretoken: csrftoken, + 'operand': 'in', + 'sender_id': userId, + 'recipent_id': contactId + }, + dataType: 'json', + success: function (json) { + $.each(json.results, function (i, v) { + var senderName = 'Вы'; + var className = 'youChat'; + if (v.sender.id == contactId) { + senderName = v.sender.username; + className = ''; + } + inbox.innerHTML += '
    ' + + '

    ' + senderName + '

    ' + v.created + '
    ' + + '

    ' + v.text + '

    '; + }); + } + }); + + $.ajax({ + url: '/api/note/', + type: 'GET', + data: { + csrfmiddlewaretoken: csrftoken, + 'operand': 'in', + 'sender_id': userId, + 'recipent_id': contactId + }, + dataType: 'json', + success: function (json) { + console.log(json.results); + var noteHtmlInbox = ''; + $.each(json.results, function (i, v) { + noteHtmlInbox += '
  • ' + v.text + '
  • '; + }); + $(".contractor-notes-block").html(noteHtmlInbox); + } + }); + + + }); + + $('.deleteMess').on('click', function (e) { e.preventDefault(); e.stopPropagation(); @@ -182,81 +281,111 @@ $(function () { var senderId = $("#chat-order-add #senderId").val(); var orderId = $("#chat-order-add #orderId").val(); - socket.add_contact_message({ - "format_type": "add_message_order", - "data": { - "sender_id": senderId, - "recipent_id": recipentId, - "chat_message": chatMessage, - "order_id": orderId, + if (chatMessage) { + $("#chat-order-add .errorEmptyMessage").hide(); + socket.add_contact_message({ + "format_type": "add_message_order", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + "order_id": orderId, - } - }); + } + + }); + $("#chat-order-add #chat").val(""); + $("#document-send-order").html(""); + } else { + $("#chat-order-add .errorEmptyMessage").show(); + } + + }); + + + $('#contact-chat-add-message').on('click', function (e) { + e.preventDefault(); + var chatMessage = $("#chat").val(); + var recipentId = $("#recipentContactId").val(); + var senderId = $("#senderContactId").val(); + if (chatMessage) { + $("#contact-chat-form .errorEmptyMessage").hide(); + socket.add_contact_message({ + "format_type": "add_message_contact", + "data": { + "sender_id": senderId, + "recipent_id": recipentId, + "chat_message": chatMessage, + } + }); + $("#chat").val(""); + $("#document-send-contact").html(""); + } else { + $("#contact-chat-form .errorEmptyMessage").show(); + } - $("#chat-order-add #chat").val(""); - $("#document-send-order").html(""); }); // Добавление отзыва $('#order-review-add').on('click', function (e) { - e.preventDefault(); - e.stopPropagation(); - var formData = $("#review-adds-form").serialize(); - $.ajax({ - url: '/api/reviews/', - type: 'POST', - beforeSend: function (xhr) { - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) - }, - data: formData, - dataType: 'json', - success: function (json) { - console.log("Успешно"); - $("#review-add").modal('hide'); - $.jGrowl("Ваш отзыв успешно добавлен", { - life: 4000 - }); - }, - error: function (e) { - console.log('error'); - console.log(e); - } - }); + e.preventDefault(); + e.stopPropagation(); + var formData = $("#review-adds-form").serialize(); + $.ajax({ + url: '/api/reviews/', + type: 'POST', + beforeSend: function (xhr) { + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data: formData, + dataType: 'json', + success: function (json) { + console.log("Успешно"); + $("#review-add").modal('hide'); + $.jGrowl("Ваш отзыв успешно добавлен", { + life: 4000 + }); + }, + error: function (e) { + console.log('error'); + console.log(e); + } + }); }); // Добавление сообщения в арбитраж $('#order-arbitration-add').on('click', function (e) { - e.preventDefault(); - e.stopPropagation(); - var formData = $("#arbitration-add-form").serialize(); - $.ajax({ - url: '/projects/arbitration/create/', - type: 'POST', - beforeSend: function (xhr) { - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) - }, - data: formData, - dataType: 'json', - success: function (json) { - console.log(json); - $("#arbitration-add").modal('hide'); - $.jGrowl("Обращение в арбитраж добавлено", { - life: 4000 - }); - }, - error: function (e) { - console.log('error'); - console.log(e); - } - }); + e.preventDefault(); + e.stopPropagation(); + var formData = $("#arbitration-add-form").serialize(); + $.ajax({ + url: '/projects/arbitration/create/', + type: 'POST', + beforeSend: function (xhr) { + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data: formData, + dataType: 'json', + success: function (json) { + console.log(json); + $("#arbitration-add").modal('hide'); + $.jGrowl("Обращение в арбитраж добавлено", { + life: 4000 + }); + }, + error: function (e) { + console.log('error'); + console.log(e); + } + }); }); - $("#upload-document-order").bind('fileuploadsubmit', function(e, data){ - data.formData = { + $("#upload-document-order").bind('fileuploadsubmit', function (e, data) { + data.formData = { sender: $("#chat-order-add #senderId").val(), recipent: $("#chat-order-add #recipentId").val(), order: $("#chat-order-add #orderId").val(), - } + } }); //Загрузка документов @@ -296,17 +425,15 @@ $(function () { .parent().addClass($.support.fileInput ? undefined : 'disabled'); //Загрузка документов - - $("#upload-document-contact").bind('fileuploadsubmit', function(e, data){ - data.formData = { - sender: $("#contact-chat-form #senderContactId").val(), - recipent: $("#contact-chat-form #recipentContactId").val(), - } + $("#upload-document-contact").bind('fileuploadsubmit', function (e, data) { + data.formData = { + sender: $("#contact-chat-form #senderContactId").val(), + recipent: $("#contact-chat-form #recipentContactId").val(), + } }); - $('#upload-document-contact').fileupload({ url: '/chat/create/', crossDomain: false, diff --git a/chat/chat.py b/chat/chat.py index 53fc19c..d2fe00e 100644 --- a/chat/chat.py +++ b/chat/chat.py @@ -94,7 +94,7 @@ class ChatHandler(websocket.WebSocketHandler): waiters = tuple(w for c, w in self.waiters if c == recipent_id or c == sender_id) for waiter in waiters: - waiter.write_message({'msg': message, 'msg_time': msg_time, 'sender_id': sender_id, 'sender_name': sender_name, 'answer_type': answer_type}) + waiter.write_message({'msg': message, 'msg_time': msg_time, 'order_id': order_id, 'recipent_id': recipent_id,'sender_id': sender_id, 'sender_name': sender_name, 'answer_type': answer_type}) def check_origin(self, origin): return True diff --git a/chat/filters.py b/chat/filters.py index 19a1ab6..1cd04b2 100644 --- a/chat/filters.py +++ b/chat/filters.py @@ -20,6 +20,7 @@ class MessageFilterSet(FilterSet): sender = RelatedFilter('users.filters.UserFilterSet') recipent = RelatedFilter('users.filters.UserFilterSet') private_type = AllLookupsFilter() + team = RelatedFilter('users.filters.TeamFilterSet') class Meta: model = Message diff --git a/chat/serializers.py b/chat/serializers.py index 6cb8c06..68c28ce 100644 --- a/chat/serializers.py +++ b/chat/serializers.py @@ -35,6 +35,7 @@ class MessageSerializer(ModelSerializer): 'sender', 'recipent', 'private_type', + 'team', ) diff --git a/chat/templates/chat_contractor.html b/chat/templates/chat_contractor.html index cf6570b..f35bfa1 100644 --- a/chat/templates/chat_contractor.html +++ b/chat/templates/chat_contractor.html @@ -58,7 +58,7 @@ Контакты - 0 + 0 Удалить контакт @@ -71,20 +71,31 @@
    - - + + + +
    -
    -

    Прикрепить файл

    - Не более 10 файлов с общим объемом 500мб +
    + +

    Прикрепить файл

    - отправить +
    + отправить
    +
    +

    Входящие документы

    +
      +
    +{# #} +{# Распечатать с помощью ресурса#} +{# #} +
    @@ -131,6 +142,7 @@ +
    @@ -433,7 +445,6 @@ $(this).removeClass('orAct'); }); $(this).addClass('orAct'); - var orderId = $(this).attr('data-id'); var recipentId = $(this).attr('data-recipent-id'); var projectId = $(this).attr('data-project-id'); @@ -447,15 +458,13 @@ $("#targetCustomerId").val(recipentId); $("#add-form-order-note #recipentNote").val(recipentId); - - var inbox = document.getElementById('message-chat-order-space'); inbox.innerHTML = ''; $.ajax({ url: '/api/message', type: 'GET', - data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId, 'team__isnull': 'true'}, dataType: 'json', success: function (json) { $.each(json.results, function (i, v) { @@ -531,7 +540,7 @@ htmlInbox += '
    ' + '

    Этап ' + v.pos + '' + v.name + '

    ' + '

    Результаты этапа:' + v.result + '

    ' + - '

    ' + v.term + '

    ' + v.cost + '
    '; + '

    до ' + v.term + '

    ' + v.cost + '
    '; }); if (statusNotAgreed) { @@ -639,67 +648,7 @@ }); }); - // Вытащить сообщения для конактов - $('.user-block').on('click', function () { - var userId = $(this).attr('data-id'); - $("#contact-chat-form #recipentId").val(userId); - $("#add-form-contractor-note #recipentNoteContractor").val(userId); - $('.user-block').each(function () { - $(this).removeClass('mesAct'); - }); - - $(this).addClass('mesAct'); - var inbox = document.getElementById('message-chat-space'); - inbox.innerHTML = ''; - $.ajax({ - url: '/api/message', - type: 'GET', - data: { - csrfmiddlewaretoken: csrftoken, - 'operand': 'in', - 'sender_id': currentChatUser, - 'recipent_id': userId - }, - dataType: 'json', - success: function (json) { - $.each(json.results, function (i, v) { - console.log(v.sender.id); - var senderName = 'Вы'; - var className = 'youChat'; - if (v.sender.id == userId) { - senderName = v.sender.username; - className = ''; - } - inbox.innerHTML += '
    ' + - '

    ' + senderName + '

    ' + v.created + '
    ' + - '

    ' + v.text + '

    '; - }); - } - }); - - $.ajax({ - url: '/api/note/', - type: 'GET', - data: {csrfmiddlewaretoken: csrftoken, - 'operand': 'in', - 'sender_id': currentChatUser, - 'recipent_id': userId}, - dataType: 'json', - success: function (json) { - console.log(json.results); - var noteHtmlInbox = ''; - $.each(json.results, function (i, v) { - noteHtmlInbox += '
  • ' + v.text + '
  • '; - - }); - $(".contractor-notes-block").html(noteHtmlInbox); - } - }); - - }); - //Добавить сообщение для исполнителей в группе - $("#add-team-chat-message").on('click', function () { var chatMessage = $("#team-chat-form #chatText").val(); var recipentId = $("#team-chat-form #recipentId").val(); @@ -727,24 +676,6 @@ $("#document-send").html(""); }); - // Добавить сообщение для контакта - $('#contact-chat-add-message').on('click', function () { - var chatMessage = $("#chat").val(); - var recipentId = $("#recipentId").val(); - var senderId = $("#senderId").val(); - - socket.add_contact_message({ - "format_type": "add_message_contact", - "data": { - "sender_id": senderId, - "recipent_id": recipentId, - "chat_message": chatMessage, - } - }); - - var inbox = $('#message-chat-space').html(); - $("#chat").val(""); - }); }); diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html index 25c510c..be61c50 100644 --- a/chat/templates/chat_customer.html +++ b/chat/templates/chat_customer.html @@ -52,7 +52,7 @@ Контакты - 0 + 0 Удалить контакт @@ -67,8 +67,8 @@
    - +
    @@ -137,6 +137,7 @@ +
    @@ -192,6 +193,14 @@
    +
    +

    Входящие документы

    +
      +{# #} +{# Распечатать с помощью ресурса#} +{# #} +
      +

      Для заметок

      @@ -229,6 +238,12 @@ var currentChatUser = {{ request.user.pk }}; var form = document.getElementById('message_form'); + $('body').on('focus',".term-picker", function(){ + $(this).datepicker({ + minDate: 0, + }); + }) + $("#reserve-button").on("click",function(e) { e.preventDefault(); $("#reserve-stage-modal").modal('show'); @@ -279,7 +294,6 @@ }); - $("#tab2").on("change","#stagesSelect", function(e){ var sumStage = $(this).find('option:selected').attr("data-stage-sum"); $("#choiceWayStage").val(sumStage); @@ -313,7 +327,7 @@ '' + '' + '' + - '' + + '' + '' + '' + '
      '; @@ -342,7 +356,7 @@ '' + '' + '' + - '' + + '' + '' + '
      '; } else { @@ -358,14 +372,11 @@ }); if (statusNotAgreed) { - var orderSecureCheckbox = ''; - if(data.secure) { - orderSecureCheckbox = "checked"; - } - htmlInbox += '
      ' + - '
      ' + + if(!data.secure) { + htmlInbox += '
      ' + + '
      ' + 'Перейти в режим безопасной сделки
      '; - + } htmlInbox +=''; @@ -598,44 +608,7 @@ $("#chat-order-add #recipentId").val(recipentId); $(".orderStagesInput").val(orderId); var inbox = document.getElementById('message-chat-order-space'); - inbox.innerHTML = ''; - $.ajax({ - url: '/api/message', - type: 'GET', - data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - dataType: 'json', - success: function (json) { - $.each(json.results, function (i, v) { - var senderName = 'Вы'; - var className = 'youChat'; - - if (v.sender.id !== currentChatUser) { - senderName = v.sender.username; - className = ''; - } - - inbox.innerHTML += '
      ' + - '

      ' + senderName + '

      ' + v.created + '
      ' + - '

      ' + v.text + '

      '; - }); - } - }); - getStages(orderId,userId,recipentId, secureOrder); - }); - - // Вытащить сообщения для конактов - $('.user-block').on('click', function () { - var userId = $(this).attr('data-id'); - $("#contact-chat-form #recipentContactId").val(userId); - $("#add-form-contractor-note #recipentNoteContractor").val(userId); - - $('.user-block').each(function () { - $(this).removeClass('mesAct'); - }); - - $(this).addClass('mesAct'); - var inbox = document.getElementById('message-chat-space'); - var docList = document.getElementById('documentSpace'); + var docList = document.getElementById('documentOrderSpace'); inbox.innerHTML = ''; docList.innerHTML = ''; @@ -644,68 +617,42 @@ type: 'GET', data:{ csrfmiddlewaretoken: csrftoken, - 'operand': 'in', - 'sender_id': currentChatUser, - 'recipent_id': userId + 'order': orderId }, dataType: 'json', - success: function (json){ console.log(json); $.each(json.results, function (i, v) { - docList.innerHTML += '
    • '+ v.file+'
    • '; + docList.innerHTML += '
    • '+ v.file+'
    • '; }); }, error: function(e){ console.log(e); } }); - $.ajax({ url: '/api/message', type: 'GET', - data: { - csrfmiddlewaretoken: csrftoken, - 'operand': 'in', - 'sender_id': currentChatUser, - 'recipent_id': userId - }, + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId,'team__isnull': 'true'}, dataType: 'json', success: function (json) { $.each(json.results, function (i, v) { var senderName = 'Вы'; var className = 'youChat'; - if (v.sender.id == userId) { + + if (v.sender.id !== currentChatUser) { senderName = v.sender.username; className = ''; } - inbox.innerHTML += '
      ' + - '

      ' + senderName + '

      ' + v.created + '
      ' + + + inbox.innerHTML += '
      ' + + '

      ' + senderName + '

      ' + v.created + '
      ' + '

      ' + v.text + '

      '; }); } }); - - }); - - $('#contact-chat-add-message').on('click', function (e) { - e.preventDefault(); - var chatMessage = $("#chat").val(); - var recipentId = $("#recipentContactId").val(); - var senderId = $("#senderContactId").val(); - - socket.add_contact_message({ - "format_type": "add_message_contact", - "data": { - "sender_id": senderId, - "recipent_id": recipentId, - "chat_message": chatMessage, - } - }); - - $("#chat").val(""); - $("#document-send-contact").html(""); + getStages(orderId,userId,recipentId, secureOrder); }); diff --git a/chat/views.py b/chat/views.py index dedf1be..8525bd5 100644 --- a/chat/views.py +++ b/chat/views.py @@ -55,7 +55,7 @@ class ChatUserView(LoginRequiredMixin, View): contacts_users = User.objects.filter(pk__in=users_ids) chat_messages = Message.objects.filter(Q(sender=request.user.pk) | Q(recipent=request.user.pk)) - orders = request.user.projects.select_related('order').exclude(order__contractor__isnull=True) + orders = request.user.projects.select_related('order').exclude(order__contractor__isnull=True, order__team__isnull=True) transaction = Transaction.objects.get_or_create(customer=request.user, type='reservation', complete=False) self.template_name = 'chat_customer.html' return render(request, self.template_name, {'contacts_users': contacts_users, @@ -65,7 +65,15 @@ class ChatUserView(LoginRequiredMixin, View): 'YANDEX_MONEY': settings.YANDEX_MONEY, }) else: - orders = request.user.orders.all() + team_ids = [] + if request.user.is_owner_team(): + team_ids.append(request.user.team.pk) + team_orders = request.user.team.orders.all() + else: + teams = Team.objects.filter(contractors__id=request.user.pk).all() + team_orders = Order.objects.filter(team_id__in=[team.pk for team in teams]).all() + + orders = Order.objects.filter(Q(contractor=request.user) | Q(team_id__in=team_ids)).all() contractor_contacts = Message.objects.values_list('sender_id', 'recipent_id').filter( Q(recipent_id=request.user.pk) | Q(sender_id=request.user.pk)).filter(Q(team_id=None)).distinct() users_ids = [] @@ -81,11 +89,7 @@ class ChatUserView(LoginRequiredMixin, View): chat_messages = Message.objects.filter(Q(sender=request.user.pk) | Q(recipent=request.user.pk)).order_by( 'created') - if request.user.is_owner_team(): - team_orders = request.user.team.orders.all() - else: - teams = Team.objects.filter(contractors__id=request.user.pk).all() - team_orders = Order.objects.filter(team_id__in=[team.pk for team in teams]).all() + self.template_name = 'chat_contractor.html' return render(request, self.template_name, {'orders': orders, diff --git a/projects/migrations/0018_auto_20160829_1751.py b/projects/migrations/0018_auto_20160829_1751.py new file mode 100644 index 0000000..9f066d2 --- /dev/null +++ b/projects/migrations/0018_auto_20160829_1751.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 14:51 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0017_arbitration'), + ] + + operations = [ + migrations.AlterField( + model_name='portfolio', + name='created', + field=models.DateTimeField(auto_created=True, auto_now_add=True), + ), + ] diff --git a/projects/migrations/0019_remove_stage_term.py b/projects/migrations/0019_remove_stage_term.py new file mode 100644 index 0000000..fe6b018 --- /dev/null +++ b/projects/migrations/0019_remove_stage_term.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 14:58 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0018_auto_20160829_1751'), + ] + + operations = [ + migrations.RemoveField( + model_name='stage', + name='term', + ), + ] diff --git a/projects/migrations/0020_stage_term.py b/projects/migrations/0020_stage_term.py new file mode 100644 index 0000000..ad39c92 --- /dev/null +++ b/projects/migrations/0020_stage_term.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 15:02 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0019_remove_stage_term'), + ] + + operations = [ + migrations.AddField( + model_name='stage', + name='term', + field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2016, 8, 29, 15, 2, 54, 818311, tzinfo=utc)), + preserve_default=False, + ), + ] diff --git a/projects/models.py b/projects/models.py index bec87d0..35ea510 100644 --- a/projects/models.py +++ b/projects/models.py @@ -251,7 +251,7 @@ class Stage(models.Model): name = models.CharField(max_length=255) order = models.ForeignKey(Order, related_name='stages') result = models.CharField(max_length=255) - term = models.IntegerField(default=0) + term = models.DateTimeField(auto_now_add=True) term_type = models.CharField(max_length=10, choices=TERMS, default='hour') status = models.CharField(choices=STATUSES, max_length=30, default='not_agreed') created = models.DateTimeField(default=timezone.now) diff --git a/projects/serializers.py b/projects/serializers.py index 48df52c..9cd0ed4 100755 --- a/projects/serializers.py +++ b/projects/serializers.py @@ -1,3 +1,4 @@ +from rest_framework import serializers from generic_relations.relations import GenericRelatedField from rest_framework.serializers import ModelSerializer, ImageField, FileField, SerializerMethodField, PrimaryKeyRelatedField @@ -49,7 +50,7 @@ class RealtySerializer(ModelSerializer): class StageSerializer(ModelSerializer): - # order = OrderSerializer() + term = serializers.DateTimeField(format="%d-%m-%Y") class Meta: model = Stage @@ -72,17 +73,6 @@ class StageSerializer(ModelSerializer): ) - # def update(self, inst, validated_data): - # import code; code.interact(local=dict(globals(), **locals())) - # inst.id = validated_data.get('id',inst.id) - # inst.name = validated_data.get('name', inst.name) - # inst.cost = validated_data.get('cost', inst.cost) - # inst.order = validated_data.get('order', inst.order) - # inst.result = validated_data.get('result', inst.result) - # inst.save() - # return inst - - class OrderSerializer(ModelSerializer): stages = StageSerializer(many=True, read_only=True) diff --git a/projects/templates/comparison.html b/projects/templates/comparison.html index 7e1d4cc..da06d86 100644 --- a/projects/templates/comparison.html +++ b/projects/templates/comparison.html @@ -76,9 +76,12 @@
      - {% ratings_widget answer.author.pk 'restList2' %} + {% if answer.author|class_name == 'User' %} + {% ratings_widget answer.author.pk 'restList2' %} + {% elif answer.author|class_name == 'Team'%} + {% ratings_team_widget answer.author.pk 'restList2' %} + {% endif %} {% if answer.author|class_name == 'User' and answer.author.cro %}
      diff --git a/projects/views.py b/projects/views.py index 0db6864..1f0ca0d 100644 --- a/projects/views.py +++ b/projects/views.py @@ -594,9 +594,9 @@ class ProjectComparisonView(DetailView): model = Project template_name = 'comparison.html' - def get_context_data(self, **kwargs): - context = super().get_context_data() - return context + # def get(self, request, **kwargs): + # self.object = self.get_object() + def add_candidate(request, answer_id, project_id): diff --git a/templates/partials/base.html b/templates/partials/base.html index f73f213..40fdcf6 100644 --- a/templates/partials/base.html +++ b/templates/partials/base.html @@ -97,7 +97,15 @@ sock.onmessage = function (event) { var notificationData = JSON.parse(event.data); - $.jGrowl("Вам пришло новое сообщение!" + notificationData.msg, {sticky: true}); + console.log(notificationData); + var outMessage = ""; + if (notificationData.answer_type == 'add_message_contact'){ + outMessage += ""+ notificationData.msg +""; + }else if((notificationData.answer_type == 'approve_stages') || (notificationData.answer_type == 'add_message_order')){ + outMessage += ""+ notificationData.msg +""; + } + + $.jGrowl("Вам пришло новое сообщение!
      " + outMessage, { life: 15000}); }; } }; diff --git a/work_sell/migrations/0007_auto_20160829_1740.py b/work_sell/migrations/0007_auto_20160829_1740.py new file mode 100644 index 0000000..2ddfec1 --- /dev/null +++ b/work_sell/migrations/0007_auto_20160829_1740.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 14:40 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('work_sell', '0006_remove_worksell_team'), + ] + + operations = [ + migrations.AlterField( + model_name='worksell', + name='created', + field=models.DateTimeField(auto_now_add=True), + ), + ] From 5e134fb5170ece068d22d033cbe773566613b600 Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Mon, 29 Aug 2016 20:04:03 +0300 Subject: [PATCH 2/2] #ARC-23 add noreply setttings --- .../migrations/0006_settings_noreply_email.py | 20 +++++++++++++++++++ common/models.py | 2 +- common/views.py | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 common/migrations/0006_settings_noreply_email.py diff --git a/common/migrations/0006_settings_noreply_email.py b/common/migrations/0006_settings_noreply_email.py new file mode 100644 index 0000000..ed85d68 --- /dev/null +++ b/common/migrations/0006_settings_noreply_email.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-29 16:59 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0005_settings_accountant_send_email'), + ] + + operations = [ + migrations.AddField( + model_name='settings', + name='noreply_email', + field=models.CharField(default='noreply@proekton.com', max_length=50), + ), + ] diff --git a/common/models.py b/common/models.py index 61edfd9..6559cdc 100644 --- a/common/models.py +++ b/common/models.py @@ -43,7 +43,7 @@ class Settings(models.Model): document_send_time_remove = models.IntegerField(default=14) recalculation_spec_time = models.TimeField() recalculation_rating_time = models.TimeField() - # worksell_count = models.PositiveIntegerField(default=20) + noreply_email = models.CharField(max_length=50,default='noreply@proekton.com') def __str__(self): return 'Настройки сайта' diff --git a/common/views.py b/common/views.py index b5b3865..1729bb3 100644 --- a/common/views.py +++ b/common/views.py @@ -52,7 +52,7 @@ class PrintDocumentCreate(BaseMixin, View): settings = Settings.objects.all().first() - subject, from_email, to = 'Заявка на распечатку', 'mukhtar@mukhtar', settings.document_send_email + subject, from_email, to = 'Заявка на распечатку', settings.noreply_email, settings.document_send_email text_content = render_to_string('document_email.txt', ctx_dict) html_content = get_template('document_email.html').render(ctx_dict) msg = EmailMultiAlternatives(subject, text_content, from_email, [to])