From 84598a1d34541e7696ed935828ada89e46cb976f Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Wed, 17 Aug 2016 15:41:09 +0300 Subject: [PATCH] #ARC-6 Fixes bugs --- chat/templates/chat_contractor.html | 27 +++++-------------- chat/templates/chat_customer.html | 26 +++++++----------- chat/testapp.py | 5 ++-- projects/forms.py | 2 ++ .../templates/contractor_portfolio_edit.html | 7 ++++- projects/views.py | 24 +++++++++++++++-- .../templatetags/ratings_widget.html | 5 ++-- users/templates/contractor_filter.html | 20 ++++++-------- users/templates/contractor_office.html | 7 +++-- users/templates/contractor_profile.html | 12 +++++---- users/templates/portfolio_create_form.html | 11 ++++---- 11 files changed, 77 insertions(+), 69 deletions(-) diff --git a/chat/templates/chat_contractor.html b/chat/templates/chat_contractor.html index 15b1fdc..60ecad5 100644 --- a/chat/templates/chat_contractor.html +++ b/chat/templates/chat_contractor.html @@ -50,21 +50,7 @@
{{ contact.username }}

- - Контакты + Контакты 0 @@ -299,7 +285,7 @@ console.log(message.msg); inbox.innerHTML += '
' + - '

ВЫ

13.0.2016
' + + '

ВЫ

Сейчас
' + '

' + message.msg + '

'; }; @@ -573,6 +559,11 @@ $('.user-block').on('click', function () { var userId = $(this).attr('data-id'); $("#contact-chat-form #recipentId").val(userId); + $('.user-block').each(function () { + $(this).removeClass('mesAct'); + }); + + $(this).addClass('mesAct'); var inbox = document.getElementById('message-chat-space'); inbox.innerHTML = ''; $.ajax({ @@ -647,10 +638,6 @@ }); var inbox = $('#message-chat-space').html(); - $('#message-chat-space').html(inbox + '
' + - '

Вы

Сейчас
' + - '

' + chatMessage + '

'); - $("#chat").val(""); }); diff --git a/chat/templates/chat_customer.html b/chat/templates/chat_customer.html index c1869f9..ebc9156 100644 --- a/chat/templates/chat_customer.html +++ b/chat/templates/chat_customer.html @@ -56,20 +56,6 @@ -
@@ -473,6 +459,12 @@ $('.user-block').on('click', function () { var userId = $(this).attr('data-id'); $("#contact-chat-form #recipentId").val(userId); + + $('.user-block').each(function () { + $(this).removeClass('mesAct'); + }); + + $(this).addClass('mesAct'); var inbox = document.getElementById('message-chat-space'); inbox.innerHTML = ''; $.ajax({ @@ -564,13 +556,13 @@ console.log(event.data); var message = JSON.parse(event.data); var inbox; - if (message.answer_type == 'contact') { + if (message.answer_type == 'contact' || message.answer_type == 'add_message_contact') { inbox = document.getElementById('message-chat-space'); - } else if (message.answer_type == 'order' || message.answer_type == 'add_order') { + } else if (message.answer_type == 'order' || message.answer_type == 'add_message_order') { inbox = document.getElementById('message-chat-order-space') } inbox.innerHTML += '
' + - '

Иванов

13.0.2016
' + + '

Вы

Сейчас
' + '

' + message.msg + '

'; }; diff --git a/chat/testapp.py b/chat/testapp.py index fe64028..7de5d58 100644 --- a/chat/testapp.py +++ b/chat/testapp.py @@ -61,12 +61,13 @@ class ChatHandler(websocket.WebSocketHandler): answer_type = message_data['format_type'] private_type = 'true' if not order_id and not team_id else 'false' + is_new = 'true' team_value = "NULL" if team_id is None else team_id order_value = "NULL" if order_id is None else order_id - insert_sql = "INSERT INTO chat_message (id,text,created, sender_id,recipent_id, private_type,team_id, order_id) " \ - "VALUES (DEFAULT,'{0}',NOW(),{1},{2},{3},{4},{5})".format(message, sender_id, recipent_id, private_type, team_value,order_value) + insert_sql = "INSERT INTO chat_message (id,text,created, sender_id,recipent_id, private_type,team_id, order_id,is_new) " \ + "VALUES (DEFAULT,'{0}',NOW(),{1},{2},{3},{4},{5},{6})".format(message, sender_id, recipent_id, private_type, team_value,order_value,is_new) yield self.db.execute(insert_sql) waiters = tuple(w for c, w in self.waiters if c == recipent_id or c == sender_id) diff --git a/projects/forms.py b/projects/forms.py index 4086dee..75783c4 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -150,6 +150,8 @@ class RealtyForm(forms.ModelForm): class PortfolioForm(forms.ModelForm): + duplicate = forms.BooleanField(required=False,label='Some label here') + class Meta: model = Portfolio fields = '__all__' diff --git a/projects/templates/contractor_portfolio_edit.html b/projects/templates/contractor_portfolio_edit.html index 06eea9c..b9c1425 100644 --- a/projects/templates/contractor_portfolio_edit.html +++ b/projects/templates/contractor_portfolio_edit.html @@ -81,13 +81,18 @@

Классификация здания

{{ form.building_classification}} +
- +{# #} + +
diff --git a/projects/views.py b/projects/views.py index 4a94efa..b81fe99 100644 --- a/projects/views.py +++ b/projects/views.py @@ -18,7 +18,7 @@ from .mixins import LastAccessMixin from .models import Project, ProjectFile, Portfolio, PortfolioPhoto, Candidate, Answer, AnswerFile, AnswerMessage, Realty, Order from archilance.mixins import BaseMixin from users.models import User, Team -from work_sell.models import Picture +from work_sell.models import Picture, WorkSell, WorkSellPhoto from .forms import ( ContractorPortfolioTrashForm, @@ -577,8 +577,23 @@ def contractor_portfolio_create(request): form = PortfolioForm(data=request.POST) # import code; code.interact(local=dict(globals(), **locals())) if form.is_valid(): + duplicate = form.cleaned_data.get('duplicate') instance = form.save(commit=False) + instance.user = request.user instance.save() + if duplicate: + work_sell = WorkSell() + work_sell.name = instance.name + work_sell.budget = instance.budget + work_sell.building_classification = instance.building_classification + work_sell.construction_type = instance.construction_type + work_sell.currency = instance.currency + work_sell.description = instance.description + work_sell.term = instance.term + work_sell.term_type = instance.term_type + work_sell.contractor = instance.user + work_sell.save() + images_ids = request.POST.get('images-ids').split(';')[:-1] for pk in images_ids: picture = Picture.objects.get(pk=pk) @@ -588,6 +603,11 @@ def contractor_portfolio_create(request): p_photo.img = temp_file p_photo.portfolio = instance p_photo.save() + if duplicate: + w_photo = WorkSellPhoto() + w_photo.img = temp_file + w_photo.worksell = work_sell + w_photo.save() data = {'status': 'ok'} else: data = {'status': 'no', 'form_errors': form.errors} @@ -602,7 +622,7 @@ class ContractorPortfolioUpdateView(UpdateView): template_name = 'contractor_portfolio_edit.html' def get_success_url(self): - return reverse('proje') + return reverse('users:contractor-profile',kwargs={'pk':self.object.user_id}) class PortfolioDelete(DeleteView): diff --git a/ratings/templates/templatetags/ratings_widget.html b/ratings/templates/templatetags/ratings_widget.html index 35d53ae..9a9305d 100644 --- a/ratings/templates/templatetags/ratings_widget.html +++ b/ratings/templates/templatetags/ratings_widget.html @@ -1,6 +1,6 @@
+ diff --git a/users/templates/contractor_filter.html b/users/templates/contractor_filter.html index 36d0b13..be86d88 100644 --- a/users/templates/contractor_filter.html +++ b/users/templates/contractor_filter.html @@ -233,6 +233,7 @@
+

- {{ p.get_full_name }} + {{ p.get_full_name }}

Программист @@ -123,10 +123,13 @@ {% if contractor.team %} {% ratings_team_widget contractor.team.pk %} {% endif %} + + {% if contractor.cro %}

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

+ {% endif %} diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index c6bb5c3..09bdffa 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -318,10 +318,11 @@
{{ contractor.contractor_resume.text }} - + +
+ -