diff --git a/assets/js/chat.js b/assets/js/chat.js index 9fa66fd..2b07259 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -100,12 +100,14 @@ function csrfSafeMethod(method) { $(function () { + setTimeout(function () { $(".user-block").first().trigger('click'); }, 10); setTimeout(function () { - $(".order-block").first().trigger('click'); + $(".order-block").last().trigger('click'); + $("a[href='#tab2']").trigger('click'); }, 100); diff --git a/chat/templates/chat_contractor.html b/chat/templates/chat_contractor.html index e288b81..19d9d13 100644 --- a/chat/templates/chat_contractor.html +++ b/chat/templates/chat_contractor.html @@ -175,6 +175,13 @@ + + +
@@ -475,8 +482,12 @@ var stagesInWork = []; var stagesResults = data.stages; var statusNotAgreed = false; + var stagesCompleted = []; if (stagesResults.length > 0) { $.each(stagesResults, function (i, v) { + if (v.status == "completed"){ + stagesCompleted.push(v); + } if(v.status == "not_agreed"){ statusNotAgreed = true; } @@ -490,10 +501,12 @@ stagesInWork.push(v); } - if (v.is_paid) { - stagesReservedHtml += '
  • Сумма за этап ' + v.pos + '.Зарезервирована.
  • '; - } else { - stagesReservedHtml += '
  • Сумма за этап ' + v.pos + '.Не зарезервирована.
  • '; + if(data.secure) { + if (v.is_paid) { + stagesReservedHtml += '
  • Сумма за этап ' + v.pos + '.Зарезервирована.
  • '; + } else { + stagesReservedHtml += '
  • Сумма за этап ' + v.pos + '.Не зарезервирована.
  • '; + } } htmlInbox += '
    ' + @@ -509,9 +522,14 @@ } } - $("#order-stages").html(htmlInbox); $(".stages-paid").html(stagesReservedHtml); + if(data.secure) { + $("#reserveSpace").show(); + + } else { + $("#reserveSpace").hide(); + } if (stagesInWork.length > 0){ $("#completeWork").show(); @@ -531,6 +549,10 @@ }else{ $("#completeWork").hide(); } + + if(stagesCompleted.length == stagesResults.length){ + $("#leaveReview").show(); + } }); @@ -592,8 +614,6 @@ }); }); - - // Вытащить сообщения для конактов $('.user-block').on('click', function () { var userId = $(this).attr('data-id'); diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html index 460d3c5..9f0bd98 100644 --- a/chat/templates/chat_customer.html +++ b/chat/templates/chat_customer.html @@ -105,7 +105,7 @@

    Заказы

    {% for order in orders %} -

    {{ order }}

    @@ -183,7 +183,11 @@
    - +

    Для заметок

    @@ -192,13 +196,6 @@
    - - - {% include 'review_add_modal.html' %} @@ -230,10 +227,9 @@ var csrftoken = getCookie('csrftoken'); $("#reserve-button").on("click",function(e) { - e.preventDefault(); + e.preventDefault(); $("#reserve-stage-modal").modal('show'); var orderId = $(this).attr('data-order-id'); - $.ajax({ url: '/api/stages/', type: 'GET', @@ -244,11 +240,13 @@ var totalSum = 0; var stagesIds = ''; $.each(json.results, function (i, v) { - console.log(v.cost); - totalSum += parseInt(v.cost); - outputValues += ''; - stagesIds += v.id + ';' + if((v.status == 'in_process') && (!v.is_paid)) { + totalSum += parseInt(v.cost); + outputValues += ''; + stagesIds += v.id + ';' + } }); + $("#stagesSelect").html(outputValues); $(".totalSum").text(totalSum); $("#choiceWayOrder").val(totalSum) @@ -293,7 +291,6 @@ type: 'GET', data:{csrfmiddlewaretoken: csrftoken}, dataType: 'json', - }).then(function(data){ var stagesResults = data.stages; var stageCount = stagesResults.length; @@ -321,8 +318,12 @@ var statusNotAgreed = true; var stagesInWork = []; var stagesPaidProcess = []; + var stagesCompleted = []; $.each(stagesResults, function (i, v) { + if (v.status == "completed"){ + stagesCompleted.push(v); + } if(!data.secure){ if(v.status == "in_process") { stagesInWork.push(v); @@ -347,7 +348,7 @@ htmlInbox += '
    ' + '

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

    ' + '

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

    ' + - '

    до Дата

    ' + v.cost + '' + + '

    до '+ v.term +'

    ' + v.cost + '' + '
    '; } @@ -377,7 +378,7 @@ var stage = stagesInWork[0]; var stageWork = '

    В работе '+ stage.name +'

    ' + '

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

    ' + - '

    Срок сдачи 25.08.2016 ' + stage.cost + 'р.

    '; + '

    Срок сдачи '+ stage.term +'' + stage.cost + 'р.

    '; if (stage.close_contractor){ stageWork += '
    -

    Кол-во денег {{ transaction.pk }}

    - + - +
    +
    diff --git a/chat/templates/review_add_modal.html b/chat/templates/review_add_modal.html index 21a2b19..762266d 100644 --- a/chat/templates/review_add_modal.html +++ b/chat/templates/review_add_modal.html @@ -24,13 +24,22 @@

    Ваш отзыв

    - - - + {% if request.user.is_customer %} + + + + + + {% else %} + + + + + {% endif %} + - - - + +
    diff --git a/chat/views.py b/chat/views.py index 676f4c5..e69a97d 100644 --- a/chat/views.py +++ b/chat/views.py @@ -16,6 +16,7 @@ class ChatUserView(LoginRequiredMixin, View): template_name = '' def get(self, request, *args, **kwargs): + print(request.path) # import code; code.interact(local=dict(globals(), **locals())) user_id = request.GET.get('user_id',None) if request.user.is_customer(): diff --git a/projects/admin.py b/projects/admin.py index d878455..2890cd5 100644 --- a/projects/admin.py +++ b/projects/admin.py @@ -33,7 +33,7 @@ class ProjectAdmin(admin.ModelAdmin): class StageAdmin(admin.ModelAdmin): - list_display = ('name','status','pos','order',) + list_display = ('name','status','pos','order','is_paid',) admin.site.register(Answer)