From 6c9ec6bf64b8dbdbf38852c87896152aaf4af819 Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Wed, 10 Aug 2016 17:55:40 +0300 Subject: [PATCH] #ARC-27 Fixes reviews bugs --- chat/templates/chat_customer.html | 215 +++++++++++++----- chat/views.py | 2 +- projects/templates/project_detail.html | 57 ++--- projects/views.py | 2 +- .../templatetags/ratings_widget.html | 2 +- ratings/templatetags/specializtions_tags.py | 1 + templates/registration/login.html | 44 ++-- users/views.py | 16 +- work_sell/templates/worksell_detail.html | 6 +- 9 files changed, 216 insertions(+), 129 deletions(-) diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html index a805400..3220cc2 100644 --- a/chat/templates/chat_customer.html +++ b/chat/templates/chat_customer.html @@ -237,6 +237,69 @@ var socket = new SocketHandler(); var form = document.getElementById('message_form'); var csrftoken = getCookie('csrftoken'); + + function getStages(orderId){ + + $.ajax({ + url: '/api/stages/', + type: 'GET', + data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, + dataType: 'json', + success: function (json) { + var stageCount = json.results.length; + if (stageCount == 0){ + stageCountVal = 1; + }else{ + stageCountVal = stageCount; + } + + var htmlInbox = ""; + + var htmlInboxStage = '

Какое кол-во этапов подразумевает работа? ' + + '

'; + + if (stageCount == 0){ + htmlInboxStage += '
' + + '

Этап 1

' + + '' + + '' + + ' />' + + '' + + '' + + '
'; + } + var statusNotAgreed = true; + $.each(json.results, function (i, v) { + if (v.status == "not_agreed") { + htmlInbox += '
' + + '

Этап

' + + '' + + '' + + '' + + '' + + '' + + '
'; + } else { + statusNotAgreed = false; + htmlInboxStage = ""; + htmlInbox += '
' + + '

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

' + + '

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

' + + '

до 16.03.2015

' + v.cost + '
'; + + } + }); + + if (statusNotAgreed) { + htmlInbox += '
Перейти в режим безопасной сделки' + + '
' + + 'отправить на согласование
'; + } + htmlInbox = htmlInboxStage + htmlInbox; + $("#order-stages").html(htmlInbox); + } + }); + } setTimeout(function(){ $(".user-block").first().trigger('click'); }, 10); @@ -245,7 +308,8 @@ $(".order-block").first().trigger('click'); }, 100); - $("#order-stages").on('click', "#addStagesForm", function(){ + $("#order-stages").on('click', "#addStagesForm", function(e){ + e.preventDefault(); $(".new-stages-form").each(function(i,v){ console.log($(this).serialize()); @@ -259,6 +323,7 @@ dataType: 'json', success: function (json) { console.log(json); + }, error: function(e){ console.log('error'); @@ -267,6 +332,30 @@ }); }); + + $(".update-stages-form").each(function(i,v){ + $.ajax({ + url: '/api/stages/' + currentStageId + '/', + type: 'PUT', + beforeSend: function(xhr){ + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')) + }, + data: $(this).serialize(), + dataType:'json', + success: function(json){ + console.log(json); + }, + + + }) + }); + + + var currentOrderId = $(this).attr('data-order-id'); + currentOrderId = parseInt(currentOrderId); + getStages(currentOrderId); + + }); $('#order-stages-tab').on('change', '#countStage', function(){ @@ -317,65 +406,67 @@ } }); - $.ajax({ - url: '/api/stages/', - type: 'GET', - data: {csrfmiddlewaretoken: csrftoken, 'order': orderId}, - dataType: 'json', - success: function (json) { - var stageCount = json.results.length; - if (stageCount == 0){ - stageCountVal = 1; - }else{ - stageCountVal = stageCount; - } - - var htmlInbox = ""; - - var htmlInboxStage = '

Какое кол-во этапов подразумевает работа? ' + - '

'; - - if (stageCount == 0){ - htmlInboxStage += '
' + - '

Этап 1

' + - '' + - '' + - ' />' + - '' + - '' + - '
'; - } - var statusNotAgreed = true; - $.each(json.results, function (i, v) { - if (v.status == "not_agreed") { - htmlInbox += '
' + - '

Этап

' + - '' + - '' + - '' + - '' + - '' + - '
'; - } else { - statusNotAgreed = false; - htmlInboxStage = ""; - htmlInbox += '
' + - '

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

' + - '

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

' + - '

до 16.03.2015

' + v.cost + '
'; - - } - }); - - if (statusNotAgreed) { - htmlInbox += '
Перейти в режим безопасной сделки' + - '
' + - 'отправить на согласование
'; - } - htmlInbox = htmlInboxStage + htmlInbox; - $("#order-stages").html(htmlInbox); - } - }); + getStages(orderId); + +{# $.ajax({#} +{# url: '/api/stages/',#} +{# type: 'GET',#} +{# data: {csrfmiddlewaretoken: csrftoken, 'order': orderId},#} +{# dataType: 'json',#} +{# success: function (json) {#} +{# var stageCount = json.results.length;#} +{# if (stageCount == 0){#} +{# stageCountVal = 1;#} +{# }else{#} +{# stageCountVal = stageCount;#} +{# }#} +{##} +{# var htmlInbox = "";#} +{##} +{# var htmlInboxStage = '

Какое кол-во этапов подразумевает работа? ' +#} +{# '

';#} +{##} +{# if (stageCount == 0){#} +{# htmlInboxStage += '
' +#} +{# '

Этап 1

' +#} +{# '' +#} +{# '' +#} +{# ' />' +#} +{# '' +#} +{# '' +#} +{# '
';#} +{# }#} +{# var statusNotAgreed = true;#} +{# $.each(json.results, function (i, v) {#} +{# if (v.status == "not_agreed") {#} +{# htmlInbox += '
' +#} +{# '

Этап

' +#} +{# '' +#} +{# '' +#} +{# '' +#} +{# '' +#} +{# '' +#} +{# '
';#} +{# } else {#} +{# statusNotAgreed = false;#} +{# htmlInboxStage = "";#} +{# htmlInbox += '
' +#} +{# '

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

' +#} +{# '

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

' +#} +{# '

до 16.03.2015

' + v.cost + '
';#} +{##} +{# }#} +{# });#} +{##} +{# if (statusNotAgreed) {#} +{# htmlInbox += '
Перейти в режим безопасной сделки' +#} +{# '
' +#} +{# 'отправить на согласование
';#} +{# }#} +{# htmlInbox = htmlInboxStage + htmlInbox;#} +{# $("#order-stages").html(htmlInbox);#} +{# }#} +{# });#} }); @@ -452,6 +543,10 @@ }); + + + + var userId = '{{ request.user.pk }}'; var SocketHandler = function () { var url = 'ws://127.0.0.1:8888/chat/' + userId + '/'; diff --git a/chat/views.py b/chat/views.py index 5c1aba6..6484f04 100644 --- a/chat/views.py +++ b/chat/views.py @@ -54,7 +54,7 @@ class ChatUserView(View): 'created') if request.user.is_owner_team(): - team_orders = request.user.team.team_orders.all() + team_orders = request.user.team.orders.all() self.template_name = 'chat_contractor.html' return render(request, self.template_name, {'orders': orders, diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 99cce29..fa93c9d 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -1,7 +1,8 @@ {% extends 'partials/base.html' %} {% load humanize %} - +{% load thumbnail %} +{% load specializtions_tags %} {% block content %} {% include 'partials/header.html' %} @@ -311,8 +312,7 @@ {% elif request.user.is_contractor %} - - +
@@ -415,11 +415,7 @@ {% elif request.user.is_customer %} - - - - - +

Исполнители

@@ -449,62 +445,48 @@

Новые исполнители

- - - - - - - - - - + + {% for answer_p in project.answers.all %}
- + {% ratings_widget answer_p.author.pk 'restList2' %} + {% if answer_p.author.cro %}

Есть допуск СРО

+ {% endif %}

Цена: - 35 000 + {{ answer_p.budget }}

- Срок: 3 недели + Срок: {{ answer_p.term }} of {{ answer_p.term_type }}

-

Опубликован: 22.04.2016

+

Опубликован: {{ answer_p.created | date:"M d, Y" }}

Кандидат - + предложить проект @@ -545,7 +527,7 @@

- Иванов Петр Иванович + Иванов Петр Иванович

13.01.2016 / 21:05 @@ -565,7 +547,7 @@

- Иванов Петр Иванович + Иванов Петр Иванович

13.01.2016 / 21:05 @@ -581,6 +563,7 @@
+ {% endfor %} {% endif %} diff --git a/projects/views.py b/projects/views.py index 5849bf0..7b4c5c3 100644 --- a/projects/views.py +++ b/projects/views.py @@ -175,7 +175,7 @@ class ProjectFilterView(BaseMixin, View): '
{realty_form}
' ).format(realty_form=pformat(realty_form.errors))) - + # import code; code.interact(local=dict(globals(), **locals())) paginator = Paginator(projects.all(), settings.PAGE_SIZE) page = request.GET.get('page') diff --git a/ratings/templates/templatetags/ratings_widget.html b/ratings/templates/templatetags/ratings_widget.html index fe7f745..35d53ae 100644 --- a/ratings/templates/templatetags/ratings_widget.html +++ b/ratings/templates/templatetags/ratings_widget.html @@ -1,4 +1,4 @@ -
    +
    • Рейтинг: {{ ratings }}
    • Безопасные сделки: 0
    • diff --git a/ratings/templatetags/specializtions_tags.py b/ratings/templatetags/specializtions_tags.py index b79e82c..ba41ca1 100644 --- a/ratings/templatetags/specializtions_tags.py +++ b/ratings/templatetags/specializtions_tags.py @@ -30,6 +30,7 @@ def ratings_widget(context, user_id, class_name=None): ratings = User.objects.get(pk=user_id).rating return { 'ratings': ratings, + 'class_name': class_name } @register.inclusion_tag("templatetags/ratings_widget.html", takes_context=True) diff --git a/templates/registration/login.html b/templates/registration/login.html index b4d02ba..b155cc5 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -1,24 +1,32 @@ {% extends 'partials/base.html' %} {% block content %} -
      -

      Вход на сайт

      -
      -
      - {{ form.errors }} - {% csrf_token %} -
      - -
      -
      - -
      -
      - -
      + {% include 'partials/header.html' %} +
      +
      +
      +

      Вход на сайт

      +
      +
      + {{ form.errors }} + {% csrf_token %} +
      + +
      +
      + +
      +
      + +
      - + + +
      + {% include 'partials/footer.html' %} +
      +
      -
      {% endblock %} -a + diff --git a/users/views.py b/users/views.py index e7a5396..951c541 100644 --- a/users/views.py +++ b/users/views.py @@ -226,13 +226,13 @@ class ContractorFilterView(BaseMixin, View): if get_teams: - teams = Team.objects.filter(Q(users__cro=cro) | Q(owner__cro=cro)) + teams = Team.objects.filter(Q(contractors__cro=cro) | Q(owner__cro=cro)) if specialization: teams = teams.filter( ( - Q(users__contractor_specializations__lft__gte=specialization.lft) - & Q(users__contractor_specializations__rght__lte=specialization.rght) + Q(contractors__contractor_specializations__lft__gte=specialization.lft) + & Q(contractors__contractor_specializations__rght__lte=specialization.rght) ) | ( Q(owner__contractor_specializations__lft__gte=specialization.lft) & Q(owner__contractor_specializations__rght__lte=specialization.rght) @@ -242,8 +242,8 @@ class ContractorFilterView(BaseMixin, View): if location: teams = teams.filter( ( - Q(users__location__lft__gte=location.lft) - & Q(users__location__rght__lte=location.rght) + Q(contractors__location__lft__gte=location.lft) + & Q(contractors__location__rght__lte=location.rght) ) | ( Q(owner__location__lft__gte=location.lft) & Q(owner__location__rght__lte=location.rght) @@ -252,19 +252,19 @@ class ContractorFilterView(BaseMixin, View): if work_type: teams = teams.filter( - Q(users__orders__project__work_type=work_type) + Q(contractors__orders__project__work_type=work_type) | Q(owner__orders__project__work_type=work_type), ) if build_classif: teams = teams.filter( - Q(users__orders__project__realty__building_classification=build_classif) + Q(contractors__orders__project__realty__building_classification=build_classif) | Q(owner__orders__project__realty__building_classification=build_classif), ) if constr_type: teams = teams.filter( - Q(users__orders__project__realty__construction_type=constr_type) + Q(contractors__orders__project__realty__construction_type=constr_type) | Q(owner__orders__project__realty__construction_type=constr_type), ) diff --git a/work_sell/templates/worksell_detail.html b/work_sell/templates/worksell_detail.html index a3ca0dd..f4e71d0 100644 --- a/work_sell/templates/worksell_detail.html +++ b/work_sell/templates/worksell_detail.html @@ -65,8 +65,8 @@