diff --git a/README.md b/README.md index 55f9bee..cb0f10f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ python manage.py makemigrations projects specializations users && \ python manage.py migrate ``` +Enable solr-thumbnail: + +``` +python manage.py makemigrations thumbnail +python manage.py migrate +``` + ``` python manage.py runserver ``` diff --git a/projects/migrations/0012_project_rejected_answers_count.py b/projects/migrations/0012_project_rejected_answers_count.py new file mode 100644 index 0000000..6b7497f --- /dev/null +++ b/projects/migrations/0012_project_rejected_answers_count.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-08-19 09:32 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0011_merge'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='rejected_answers_count', + field=models.PositiveIntegerField(default=0), + ), + ] diff --git a/projects/models.py b/projects/models.py index 96c8551..a1cf8e2 100644 --- a/projects/models.py +++ b/projects/models.py @@ -87,6 +87,7 @@ class Project(models.Model): name = models.CharField(max_length=255) price_and_term_required = models.BooleanField(default=False) realty = models.ForeignKey(Realty, blank=True, null=True, related_name='projects') + rejected_answers_count = models.PositiveIntegerField(default=0) specialization = TreeForeignKey(Specialization, related_name='projects') state = models.CharField(default='active', max_length=20, choices=STATES) term = models.IntegerField(default=0) diff --git a/projects/templates/project_detail.html b/projects/templates/project_detail.html index bfb462e..3b793a2 100644 --- a/projects/templates/project_detail.html +++ b/projects/templates/project_detail.html @@ -453,7 +453,7 @@ - {% elif request.user.is_customer and project.answers.exists %} + {% elif request.user.is_customer and project in request.user.projects.all %} @@ -466,169 +466,184 @@
-
-
-

Сравнить кандидатов

-
-
- -
-

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

-
- - {% for answer in project.answers.all %} -
-
-
- -
- {% if answer.author.avatar %} - execitor-image - {% else %} - execitor-image + + {% if project.answers.exists %} + {% if project.candidates.count > 1 %} + + {% endif %} + +
+

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

+
+ + {% for answer in project.answers.all %} +
+
+
+ +
+ {% if answer.author.avatar %} + execitor-image + {% else %} + execitor-image + {% endif %} +
+
+ +

+ {% 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' %} - {{ answer.author.get_full_name }} [{{ answer.author.username }}] - {% elif answer.author|class_name == 'Team' %} - {{ answer.author.name }} + {% if answer.author.contractor_status == 'free' %} +
Свободен
+ {% endif %} {% endif %} -

- - +
- {% if answer.author|class_name == 'User' %} - {% if answer.author.contractor_status == 'free' %} -
Свободен
+
+ {% ratings_widget answer.author.pk 'restList2' %} + + {% if answer.author|class_name == 'User' and answer.author.cro %} +
+
+

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

+
+ {% elif answer.author|class_name == 'Team' %} + + +
+
+

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

+
{% endif %} - {% endif %} -
- -
- {% ratings_widget answer.author.pk 'restList2' %} +
- {% if answer.author|class_name == 'User' and answer.author.cro %} -
-
-

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

-
- {% elif answer.author|class_name == 'Team' %} - +
+

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

+

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

+

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

+
+ +
+ + Кандидат + -
-
-

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

-
- {% endif %} -
- -
-

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

-

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

-

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

-
- - - - предложить проект - +
+ {% for portf in answer.portfolios.all %} +
+
+
+
+
+
+
+ {% endfor %} +
-
- {% csrf_token %} - - отказ -
-
- -
- {% for portf in answer.portfolios.all %} -
-
-
-
+
+ {% for message in answer.messages.all %} +
+
+ {% if message.is_sender_customer %} +

+ {{ project.customer.get_full_name }} +

+ {% else %} +

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

+ {% endif %} + + + {{ message.created }} + + +

+ {{ message.text }} +

-
- {% endfor %} -
- -
- {% for message in answer.messages.all %} + {% endfor %} +
+{# #} +
- {% if message.is_sender_customer %} -

- {{ project.customer.get_full_name }} -

- {% else %} -

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

- {% endif %} - - - {{ message.created }} - - -

- {{ message.text }} -

+
+ {% csrf_token %} + + +
+
+
- {% endfor %} - -
-{# #} - -
-
- {% csrf_token %} - - -
-
-
-
-
- {% endfor %} + {% endfor %} + {% endif %} + + + + + + + + + + {% endif %} diff --git a/projects/views.py b/projects/views.py index 9aa48fb..ca8d423 100644 --- a/projects/views.py +++ b/projects/views.py @@ -4,7 +4,7 @@ from django.contrib.auth.mixins import PermissionRequiredMixin, LoginRequiredMix from django.core.files.base import ContentFile from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.urlresolvers import reverse, reverse_lazy -from django.db.models import Q +from django.db.models import Q, F from django.http import HttpResponseForbidden, HttpResponseRedirect, HttpResponse, Http404 from django.shortcuts import render, get_object_or_404, redirect from django.views.generic import ListView, DetailView, CreateView, DeleteView, View, UpdateView, TemplateView, FormView @@ -181,8 +181,13 @@ class ContractorRejectProjectAnswerView(BaseMixin, View): def post(self, request, *args, **kwargs): answer = get_object_or_404(request.user.contractor_answers, pk=kwargs.get('pk')) + project = answer.project + answer.delete() + project.rejected_answers_count = F('rejected_answers_count') + 1 + project.save() + messages.info(request, 'Вы успешно отказались от проекта') redirect_to = request.POST.get('next') @@ -204,6 +209,9 @@ class CustomerRejectProjectAnswerView(BaseMixin, View): answer.delete() + project.rejected_answers_count = F('rejected_answers_count') + 1 + project.save() + messages.info(request, 'Вы успешно отказали пользователю в проекте') redirect_to = request.POST.get('next')