From fd5f044a45219da52bff2f751c062707747041a1 Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Wed, 17 Aug 2016 10:37:02 +0300 Subject: [PATCH 1/2] #ARC-9 Add urls --- users/urls.py | 6 ------ users/views.py | 16 ++++------------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/users/urls.py b/users/urls.py index acb7e85..251640e 100755 --- a/users/urls.py +++ b/users/urls.py @@ -10,9 +10,7 @@ from .views import ( CustomerProfileOpenProjectsView, CustomerProfileReviewsView, CustomerProfileTrashedProjectsView, - send_mail_test, UserFinancialInfoEditView, - UserListView, UserProfileEditView, TeamCreateView, ContractorResumeUpdateView, @@ -24,7 +22,6 @@ from .views import ( app_name = 'users' urlpatterns = [ - urls.url(r'^(?P\d+)/edit/$', UserProfileEditView.as_view(), name='user-profile-edit'), urls.url(r'^(?P\d+)/financial-info/edit/$', UserFinancialInfoEditView.as_view(), name='user-financial-info-edit'), @@ -36,12 +33,9 @@ urlpatterns = [ urls.url(r'^contractors/$', ContractorFilterView.as_view(), name='contractor-filter'), urls.url(r'^contractors/resume/(?P\d+)/edit/$', ContractorResumeUpdateView.as_view(), name='contractor-resume-update'), - urls.url(r'^contractors/team/create/$', TeamCreateView.as_view(), name='team-create'), urls.url(r'^contractorsresumefiles/create/$', contractor_resumefile_create, name='contractor-resume-file-create'), urls.url(r'^contractors/(?P\d+)/$', ContractorProfileDetailView.as_view(), name='contractor-profile'), urls.url(r'^contractor-office/(?P\d+)/$', ContractorOfficeDetailView.as_view(), name='contractor-office'), urls.url(r'^contractor-office/(?P\d+)/open-projects/$', ContractorOfficeOpenProjectsView.as_view(), name='contractor-office-open-projects'), - - urls.url(r'^test/$', send_mail_test), ] diff --git a/users/views.py b/users/views.py index 15700d9..f0a600a 100644 --- a/users/views.py +++ b/users/views.py @@ -38,17 +38,6 @@ from .forms import ( ) -def send_mail_test(request): - send_mail('Subject here', 'Here is the message.Mukhtar hello ', '', ['muhtarzubanchi05@gmail.com'], fail_silently=False) - return HttpResponse("Mail send") - - -class UserListView(ListView): - model = User - template_name = 'users_list.html' - context_object_name = 'users' - - class UserProfileEditView(BaseMixin, View): form_class = UserProfileEditForm template_name = 'user_profile_edit.html' @@ -545,6 +534,10 @@ class CustomerProfileCurrentProjectsView(BaseMixin, DetailView): context_object_name = 'customer' +def add_user_in_team(request): + pass + + class TeamCreateView(View): form_class = TeamForm @@ -641,4 +634,3 @@ class CustomerProfileReviewsView(BaseMixin, View): return render(request, self.template_name, context) -# import code; code.interact(local=dict(globals(), **locals())) From 84598a1d34541e7696ed935828ada89e46cb976f Mon Sep 17 00:00:00 2001 From: Mukhtar Date: Wed, 17 Aug 2016 15:41:09 +0300 Subject: [PATCH 2/2] #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 @@

- - Контакты + Контакты 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 @@
+
  • Рейтинг: 1245
  • Безопасные сделки: 5
  • @@ -335,13 +336,16 @@ смотреть профиль + {% if request.user.is_customer %}
  • предложить проект
  • + {% endif %} +
  • - + написать сообщение
  • @@ -384,21 +388,13 @@
    - + {% ratings_widget obj.pk 'restList2' %} + {% if obj.cro %}

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

    + {% endif %}
    diff --git a/users/templates/contractor_office.html b/users/templates/contractor_office.html index 23b6f9d..4aec367 100644 --- a/users/templates/contractor_office.html +++ b/users/templates/contractor_office.html @@ -68,7 +68,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 }} - + +
+ -