|
|
|
|
@ -14,7 +14,7 @@ import natsort |
|
|
|
|
import pydash as _; _.map = _.map_; _.filter = _.filter_ |
|
|
|
|
|
|
|
|
|
from .mixins import CheckForUserMixin |
|
|
|
|
from .models import User, Team, ContractorFinancialInfo |
|
|
|
|
from .models import User, Team, UserFinancialInfo |
|
|
|
|
from archilance import util |
|
|
|
|
from archilance.mixins import BaseMixin |
|
|
|
|
from projects.forms import PortfolioForm |
|
|
|
|
@ -25,7 +25,7 @@ from work_sell.forms import WorkSellForm |
|
|
|
|
|
|
|
|
|
from .forms import ( |
|
|
|
|
ContractorFilterForm, |
|
|
|
|
ContractorFinancicalInfoForm, |
|
|
|
|
UserFinancicalInfoForm, |
|
|
|
|
CustomerProfileProjectRealtyForm, |
|
|
|
|
UserEditForm, |
|
|
|
|
) |
|
|
|
|
@ -260,12 +260,14 @@ class CustomerProfileOpenProjectsView(BaseMixin, View): |
|
|
|
|
customer = get_object_or_404(User.customer_objects, pk=kwargs.get('pk')) |
|
|
|
|
form = self.form_class(request.GET, request=request, customer=customer) |
|
|
|
|
projects = customer.projects.filter(state='active') |
|
|
|
|
trashed_projects = customer.projects.filter(state='trashed') |
|
|
|
|
|
|
|
|
|
if form.is_valid(): |
|
|
|
|
realty = form.cleaned_data.get('realty') |
|
|
|
|
|
|
|
|
|
if realty: |
|
|
|
|
projects = projects.filter(realty=realty) |
|
|
|
|
trashed_projects = trashed_projects.filter(realty=realty) |
|
|
|
|
else: |
|
|
|
|
if form.errors: |
|
|
|
|
messages.info(request, ( |
|
|
|
|
@ -290,7 +292,7 @@ class CustomerProfileOpenProjectsView(BaseMixin, View): |
|
|
|
|
'customer': customer, |
|
|
|
|
|
|
|
|
|
'open_project_count': projects.paginator.count, |
|
|
|
|
'trashed_project_count': customer.projects.filter(state='trashed').count(), |
|
|
|
|
'trashed_project_count': trashed_projects.count(), |
|
|
|
|
|
|
|
|
|
'is_paginated': True, |
|
|
|
|
'page_obj': projects, |
|
|
|
|
@ -308,12 +310,14 @@ class CustomerProfileTrashedProjectsView(BaseMixin, View): |
|
|
|
|
customer = get_object_or_404(User.customer_objects, pk=kwargs.get('pk')) |
|
|
|
|
form = self.form_class(request.GET, request=request, customer=customer) |
|
|
|
|
projects = customer.projects.filter(state='trashed') |
|
|
|
|
open_projects = customer.projects.filter(state='active') |
|
|
|
|
|
|
|
|
|
if form.is_valid(): |
|
|
|
|
realty = form.cleaned_data.get('realty') |
|
|
|
|
|
|
|
|
|
if realty: |
|
|
|
|
projects = projects.filter(realty=realty) |
|
|
|
|
open_projects = open_projects.filter(realty=realty) |
|
|
|
|
else: |
|
|
|
|
if form.errors: |
|
|
|
|
messages.info(request, ( |
|
|
|
|
@ -337,7 +341,7 @@ class CustomerProfileTrashedProjectsView(BaseMixin, View): |
|
|
|
|
'projects': projects, |
|
|
|
|
'customer': customer, |
|
|
|
|
|
|
|
|
|
'open_project_count': customer.projects.filter(state='active').count(), |
|
|
|
|
'open_project_count': open_projects.count(), |
|
|
|
|
'trashed_project_count': projects.paginator.count, |
|
|
|
|
|
|
|
|
|
'is_paginated': True, |
|
|
|
|
@ -372,14 +376,34 @@ class CustomerProfileReviewsView(BaseMixin, View): |
|
|
|
|
return render(request, self.template_name, context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomerProfileEditView(CheckForUserMixin, View): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContractorProfileEditView(CheckForUserMixin, View): |
|
|
|
|
form_class = UserEditForm |
|
|
|
|
template_name = 'customer_profile_edit.html' |
|
|
|
|
template_name = 'contractor_profile_edit.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
instance = get_object_or_404(User, pk=request.user.pk) |
|
|
|
|
form = self.form_class(instance=instance) |
|
|
|
|
nodes = Specialization.objects.all() |
|
|
|
|
root = util.get_or_none(Specialization, name='_root') |
|
|
|
|
nodes = root.get_descendants('lft') |
|
|
|
|
|
|
|
|
|
return render(request, self.template_name, {'form': form, 'nodes': nodes}) |
|
|
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
|
@ -387,22 +411,31 @@ class CustomerProfileEditView(CheckForUserMixin, View): |
|
|
|
|
form = self.form_class(request.POST, request.FILES, instance=instance) |
|
|
|
|
if form.is_valid(): |
|
|
|
|
# import code; code.interact(local=dict(globals(), **locals())) |
|
|
|
|
form.save() |
|
|
|
|
messages.info(request, 'Отправили post запрос') |
|
|
|
|
return redirect(reverse('users:customer-profile-open-projects', kwargs={'pk': request.user.pk})) |
|
|
|
|
instance = form.save(commit=False) |
|
|
|
|
instance.save() |
|
|
|
|
messages.info(request, 'Данные успешно отредактированы') |
|
|
|
|
return redirect(reverse('users:contractor-edit', kwargs={'pk': request.user.pk})) |
|
|
|
|
|
|
|
|
|
return render(request, self.template_name, {'form': form}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContractorProfileEditView(CheckForUserMixin, View): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomerProfileEditView(CheckForUserMixin, View): |
|
|
|
|
form_class = UserEditForm |
|
|
|
|
template_name = 'contractor_profile_edit.html' |
|
|
|
|
template_name = 'customer_profile_edit.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
instance = get_object_or_404(User, pk=request.user.pk) |
|
|
|
|
form = self.form_class(instance=instance) |
|
|
|
|
root = util.get_or_none(Specialization, name='_root') |
|
|
|
|
nodes = root.get_descendants('lft') |
|
|
|
|
|
|
|
|
|
nodes = Specialization.objects.all() |
|
|
|
|
return render(request, self.template_name, {'form': form, 'nodes': nodes}) |
|
|
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
|
@ -410,17 +443,36 @@ class ContractorProfileEditView(CheckForUserMixin, View): |
|
|
|
|
form = self.form_class(request.POST, request.FILES, instance=instance) |
|
|
|
|
if form.is_valid(): |
|
|
|
|
# import code; code.interact(local=dict(globals(), **locals())) |
|
|
|
|
instance = form.save(commit=False) |
|
|
|
|
instance.save() |
|
|
|
|
messages.info(request, 'Данные успешно отредактированы') |
|
|
|
|
return redirect(reverse('users:contractor-edit', kwargs={'pk': request.user.pk})) |
|
|
|
|
|
|
|
|
|
form.save() |
|
|
|
|
messages.info(request, 'Отправили post запрос') |
|
|
|
|
return redirect(reverse('users:customer-profile-open-projects', kwargs={'pk': request.user.pk})) |
|
|
|
|
return render(request, self.template_name, {'form': form}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContractorFinancialInfoEdit(CheckForUserMixin, View): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserFinancialInfoEditView(CheckForUserMixin, View): |
|
|
|
|
template_name = 'contractor_financical_info_edit.html' |
|
|
|
|
form_class = ContractorFinancicalInfoForm |
|
|
|
|
form_class = UserFinancicalInfoForm |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
instance = request.user.contractor_financial_info |
|
|
|
|
|