From 4a13479fac6b617888c43fe13d6af83aa1647762 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Wed, 10 Aug 2016 18:45:09 +0300 Subject: [PATCH 1/3] #ARC-14 --- .../management/commands/generate_users.py | 1 + projects/models.py | 2 +- projects/templates/project_detail.html | 297 +++++++++--------- projects/views.py | 2 + 4 files changed, 154 insertions(+), 148 deletions(-) diff --git a/archilance/management/commands/generate_users.py b/archilance/management/commands/generate_users.py index 5940f83..90ae119 100644 --- a/archilance/management/commands/generate_users.py +++ b/archilance/management/commands/generate_users.py @@ -86,6 +86,7 @@ class Command(BaseCommand): email='%s@example.com' % username, is_active=True, contractor_status=_.sample(User.STATUSES)[0], + cro=_.sample((True, False)), ) users = _.times(create_user, 500) diff --git a/projects/models.py b/projects/models.py index 4e3229a..25b26d7 100644 --- a/projects/models.py +++ b/projects/models.py @@ -50,7 +50,7 @@ class Realty(models.Model): construction_type = models.ForeignKey(ConstructionType, related_name='realties') location = TreeForeignKey('common.Location', related_name='realties', null=True, blank=True) name = models.CharField(max_length=255) - user = models.ForeignKey(User, related_name='realties') + user = models.ForeignKey(User, related_name='realties') # Do we actually need this field? def __str__(self): return self.name diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 99cce29..dfacf97 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -163,153 +163,156 @@ - {% if request.user.is_contractor and request.user.contractor_answers.exists %} - - - - - - {% with answer=request.user.contractor_answers.first %} -
-
-
- -
- {% if answer.author.avatar %} - execitor-image - {% else %} - execitor-image - {% endif %} -
-
-

- {{ answer.author.get_full_name }} [{{ answer.author.username }}] -

- - - {% if answer.author|class_name == 'User' %} - {% if answer.author.contractor_status == 'free' %} -
Свободен
- {% endif %} - {% endif %} -
-
- - -
-
-

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

-
-
-
-

- Цена: - {{ answer.budget|intcomma }} - -

-

- Срок: {{ answer.term }} {{ answer.get_term_type_display|decap }} -

-

Опубликован: {{ answer.created }}

-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

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

- - 13.01.2016 / 21:05 - -
- - - - - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio. -

-
-
-
-
-

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

- - 13.01.2016 / 21:05 - -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio. -

- - Ответить - -
-
-
-
-
- {% endwith %} - - - - - - {% elif request.user.is_contractor %} +{# {% if request.user.is_contractor and request.user.contractor_answers.exists and request.user.contractor_answers.first in project.answers.all %}#} +{# #} +{# #} +{# #} +{# #} +{# #} +{# {% with answer=request.user.contractor_answers.first %}#} +{#
#} +{#
#} +{#
#} +{# #} +{#
#} +{# {% if answer.author.avatar %}#} +{# execitor-image#} +{# {% else %}#} +{# execitor-image#} +{# {% endif %}#} +{#
#} +{#
#} +{#

#} +{# {{ answer.author.get_full_name }} [{{ answer.author.username }}]#} +{#

#} +{# #} +{# #} +{# {% if answer.author|class_name == 'User' %}#} +{# {% if answer.author.contractor_status == 'free' %}#} +{#
Свободен
#} +{# {% endif %}#} +{# {% endif %}#} +{#
#} +{#
#} +{# #} +{# #} +{# {% if answer.author|class_name == 'User' %}#} +{#
#} +{#
#} +{#

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

#} +{#
#} +{# {% else %}#} +{# ...#} +{# {% endif %}#} +{#
#} +{#
#} +{#

#} +{# Цена:#} +{# {{ answer.budget|intcomma }}#} +{# #} +{#

#} +{#

#} +{# Срок: {{ answer.term }} {{ answer.get_term_type_display|decap }}#} +{#

#} +{#

Опубликован: {{ answer.created }}

#} +{#
#} +{# #} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{#

#} +{# Иванов Петр Иванович #} +{#

#} +{# #} +{# 13.01.2016 / 21:05#} +{# #} +{#
#} +{# #} +{# #} +{# #} +{# #} +{# #} +{#
#} +{#

#} +{# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio.#} +{#

#} +{#
#} +{#
#} +{#
#} +{#
#} +{#

#} +{# Иванов Петр Иванович #} +{#

#} +{# #} +{# 13.01.2016 / 21:05#} +{# #} +{#

#} +{# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio.#} +{#

#} +{# #} +{# Ответить#} +{# #} +{#
#} +{#
#} +{#
#} +{#
#} +{#
#} +{# {% endwith %}#} + + + +{# {% elif request.user.is_contractor and not request.user.contractor_answers.exists %}#} + {% if request.user.is_contractor and not request.user.contractor_answers.exists %} diff --git a/projects/views.py b/projects/views.py index d7cecf1..f3f5f7d 100644 --- a/projects/views.py +++ b/projects/views.py @@ -44,6 +44,8 @@ class ProjectDetailWithContractorAnswerView(BaseMixin, View): project = get_object_or_404(Project, pk=kwargs.get('pk')) context.update({'project': project}) + # context.update({'tmp_answer': ...}) # Tmp + if request.user.is_authenticated() and request.user.is_contractor(): form = self.form_class(request=request) context.update({'form': form}) From 057178340eddb5f92aaf10c949b549edb0bd28cc Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Thu, 11 Aug 2016 11:43:06 +0300 Subject: [PATCH 2/3] #ARC-14 --- projects/templates/project_detail.html | 319 +++++++++++++------------ projects/urls.py | 4 +- projects/views.py | 2 +- 3 files changed, 169 insertions(+), 156 deletions(-) diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index d1e8db7..2ab204b 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -164,158 +164,158 @@ -{# {% if request.user.is_contractor and request.user.contractor_answers.exists and request.user.contractor_answers.first in project.answers.all %}#} -{# #} -{# #} -{# #} -{# #} -{# #} -{# {% with answer=request.user.contractor_answers.first %}#} -{#
#} -{#
#} -{#
#} -{# #} -{#
#} -{# {% if answer.author.avatar %}#} -{# execitor-image#} -{# {% else %}#} -{# execitor-image#} -{# {% endif %}#} -{#
#} -{#
#} -{#

#} -{# {{ answer.author.get_full_name }} [{{ answer.author.username }}]#} -{#

#} -{# #} -{# #} -{# {% if answer.author|class_name == 'User' %}#} -{# {% if answer.author.contractor_status == 'free' %}#} -{#
Свободен
#} -{# {% endif %}#} -{# {% endif %}#} -{#
#} -{#
#} -{# #} -{# #} -{# {% if answer.author|class_name == 'User' %}#} -{#
#} -{#
#} -{#

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

#} -{#
#} -{# {% else %}#} -{# ...#} -{# {% endif %}#} -{#
#} -{#
#} -{#

#} -{# Цена:#} -{# {{ answer.budget|intcomma }}#} -{# #} -{#

#} -{#

#} -{# Срок: {{ answer.term }} {{ answer.get_term_type_display|decap }}#} -{#

#} -{#

Опубликован: {{ answer.created }}

#} -{#
#} -{# #} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{#

#} -{# Иванов Петр Иванович #} -{#

#} -{# #} -{# 13.01.2016 / 21:05#} -{# #} -{#
#} -{# #} -{# #} -{# #} -{# #} -{# #} -{#
#} -{#

#} -{# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio.#} -{#

#} -{#
#} -{#
#} -{#
#} -{#
#} -{#

#} -{# Иванов Петр Иванович #} -{#

#} -{# #} -{# 13.01.2016 / 21:05#} -{# #} -{#

#} -{# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio.#} -{#

#} -{# #} -{# Ответить#} -{# #} -{#
#} -{#
#} -{#
#} -{#
#} -{#
#} -{# {% endwith %}#} - - - -{# {% elif request.user.is_contractor and not request.user.contractor_answers.exists %}#} - {% if request.user.is_contractor and not request.user.contractor_answers.exists %} + {% if False and request.user.is_contractor and request.user.contractor_answers.exists and request.user.contractor_answers.first in project.answers.all %} + + + + + + {% with answer=request.user.contractor_answers.first %} +
+
+
+ +
+ {% if answer.author.avatar %} + execitor-image + {% else %} + execitor-image + {% endif %} +
+
+

+ {{ answer.author.get_full_name }} [{{ answer.author.username }}] +

+ + + {% if answer.author|class_name == 'User' %} + {% if answer.author.contractor_status == 'free' %} +
Свободен
+ {% endif %} + {% endif %} +
+
+ + + {% if answer.author|class_name == 'User' %} +
+
+

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

+
+ {% else %} + ... + {% endif %} +
+
+

+ Цена: + {{ answer.budget|intcomma }} + +

+

+ Срок: {{ answer.term }} {{ answer.get_term_type_display|decap }} +

+

Опубликован: {{ answer.created }}

+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

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

+ + 13.01.2016 / 21:05 + +
+ + + + + +
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio. +

+
+
+
+
+

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

+ + 13.01.2016 / 21:05 + +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio. +

+ + Ответить + +
+
+
+
+
+ {% endwith %} + + + + + {% elif request.user.is_contractor and not request.user.contractor_answers.exists %} + -
@@ -418,7 +418,11 @@ {% elif request.user.is_customer %} - + + + + +

Исполнители

@@ -448,7 +452,16 @@

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

- + + + + + + + + + + {% for answer_p in project.answers.all %}
diff --git a/projects/urls.py b/projects/urls.py index c16f654..ad497a8 100644 --- a/projects/urls.py +++ b/projects/urls.py @@ -4,6 +4,7 @@ from django.views.generic import TemplateView from .views import ( add_candidate, contractor_portfolio_create, + ContractorPortfolioTrashView, ContractorPortfolioUpdateView, CustomerProjectCreateView, CustomerProjectDeleteView, @@ -12,9 +13,8 @@ from .views import ( CustomerProjectTrashView, OfferOrderView, ProjectComparisonView, - ProjectFilterView, ProjectDetailWithContractorAnswerView, - ContractorPortfolioTrashView, + ProjectFilterView, ) app_name = 'projects' diff --git a/projects/views.py b/projects/views.py index 86a98fb..2ed964c 100644 --- a/projects/views.py +++ b/projects/views.py @@ -21,6 +21,7 @@ from users.models import User from work_sell.models import Picture from .forms import ( + ContractorPortfolioTrashForm, ContractorProjectAnswerForm, CustomerProjectDeleteForm, CustomerProjectEditForm, @@ -31,7 +32,6 @@ from .forms import ( ProjectFilterForm, ProjectFilterRealtyForm, RealtyForm, - ContractorPortfolioTrashForm, ) From 9aee1ec432384b72a63851968928383586ebc961 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Thu, 11 Aug 2016 20:05:33 +0300 Subject: [PATCH 3/3] #ARC-14 --- projects/models.py | 2 +- projects/templates/project_detail.html | 269 +++++++++--------- projects/views.py | 31 +- .../trash/contractor_project-detail.html | 14 +- 4 files changed, 170 insertions(+), 146 deletions(-) diff --git a/projects/models.py b/projects/models.py index 25b26d7..dd83ce5 100644 --- a/projects/models.py +++ b/projects/models.py @@ -133,7 +133,7 @@ class Answer(models.Model): author = GenericForeignKey('content_type', 'object_id') def __str__(self): - return self.text + return "{author}'s answer ({id})".format(author=type(self.author).__name__, id=self.pk) class Meta: verbose_name = 'Отклик на проект' diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index 2ab204b..7651f06 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -157,22 +157,16 @@ - - - - - - - - {% if False and request.user.is_contractor and request.user.contractor_answers.exists and request.user.contractor_answers.first in project.answers.all %} + {% if request.user.is_contractor %} + - {% with answer=request.user.contractor_answers.first %} + {% if answer %}
-
+
@@ -183,9 +177,15 @@ {% endif %}
+

- {{ answer.author.get_full_name }} [{{ answer.author.username }}] + {% if answer.author|class_name == 'User' %} + {{ answer.author.get_full_name }} [{{ answer.author.username }}] + {% elif answer.author|class_name == 'Team' %} + {{ answer.author.name }} + {% endif %}

+ {% if answer.author|class_name == 'User' %} @@ -208,12 +208,19 @@ {% if answer.author|class_name == 'User' %} -
-
-

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

-
- {% else %} - ... + {% if answer.author.cro %} +
+
+

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

+
+ {% endif %} + {% elif answer.author|class_name == 'Team' %} +{# {% if any of these motherfuckers "answer.author.contractors.all" got a cro, then... %}#} +
+
+

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

+
+{# {% endif %}#} {% endif %}
@@ -228,46 +235,31 @@

Опубликован: {{ answer.created }}

+ + + + +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {% for portf in answer.portfolios.all %} +
+
+
+
+
-
+ {% endfor %}
+ + + + +
@@ -289,6 +281,10 @@

+ + + +

@@ -306,112 +302,107 @@

+ + +
- {% endwith %} - - - - - {% elif request.user.is_contractor and not request.user.contractor_answers.exists %} - - - - - - {% csrf_token %} - - -
-
-
-

Стоимость {{ form.budget.errors.as_text }}

- + {% else %} + + {% csrf_token %} + + +
+
+
+

Стоимость {{ form.budget.errors.as_text }}

+ +
+
+ +
+
+ {{ form.currency }} +
+
+ +
+
+

Срок {{ form.term.errors.as_text }}

+ +
+
+ +
+
+ {{ form.term_type }} +
-
-
- {{ form.currency }} +
+
+
+

Текст {{ form.text.errors.as_text }}

+ +
+
-
-
-

Срок {{ form.term.errors.as_text }}

- +
+
+

Портфолио {{ form.portfolios.errors.as_text }}

+ +
    + {% for p in request.user.portfolios.all %} +
  • + + + {{ p.name }} +
  • + {% endfor %} +
-
-
- {{ form.term_type }} +
+
+
+
+ Не более 10 файлов общим объемом до 500 Мб +
+ +
    + +
+
-
- -
-
-
-

Текст {{ form.text.errors.as_text }}

- + +
+
+ {{ form.secure_deal_only }} Работаю только по безопасной сделке
-
-
- -
-
-

Портфолио {{ form.portfolios.errors.as_text }}

- -
    - {% for p in request.user.portfolios.all %} -
  • - - - {{ p.name }} -
  • - {% endfor %} -
-
-
- -
-
-
-
- Не более 10 файлов общим объемом до 500 Мб -
- -
    - -
+ +
+
+
-
- -
-
- {{ form.secure_deal_only }} Работаю только по безопасной сделке -
-
- -
-
- -
-
- -
- + +
+ + {% endif %} diff --git a/projects/views.py b/projects/views.py index 2ed964c..b4b6758 100644 --- a/projects/views.py +++ b/projects/views.py @@ -17,7 +17,7 @@ import re from .mixins import LastAccessMixin from .models import Project, ProjectFile, Portfolio, PortfolioPhoto,Candidate, Answer, AnswerFile, Realty, Order from archilance.mixins import BaseMixin -from users.models import User +from users.models import User, Team from work_sell.models import Picture from .forms import ( @@ -45,11 +45,32 @@ class ProjectDetailWithContractorAnswerView(BaseMixin, View): project = get_object_or_404(Project, pk=kwargs.get('pk')) context.update({'project': project}) - # context.update({'tmp_answer': ...}) # Tmp - if request.user.is_authenticated() and request.user.is_contractor(): - form = self.form_class(request=request) - context.update({'form': form}) + project_answers = project.answers.all() + got_answer = None + contractor = request.user + answer = contractor.contractor_answers.first() + + if answer and answer in project_answers: + got_answer = True + else: + team = None + answer = None + + try: team = contractor.team + except Team.DoesNotExist: pass + + if team: + answer = team.answers.first() + + if answer and answer in project_answers: + got_answer = True + + if got_answer: + context.update({'answer': answer}) + else: + form = self.form_class(request=request) + context.update({'form': form}) return render(request, self.template_name, context) diff --git a/templates/trash/contractor_project-detail.html b/templates/trash/contractor_project-detail.html index 04cd064..7946573 100644 --- a/templates/trash/contractor_project-detail.html +++ b/templates/trash/contractor_project-detail.html @@ -231,6 +231,18 @@ отказ
+ + + + + + + + + + + +
@@ -352,4 +364,4 @@ - \ No newline at end of file +