remotes/origin/setup
ArturBaybulatov 10 years ago
parent ec8da23d62
commit 6048dc1f89
  1. 1
      archilance/management/commands/tmp.py
  2. 1
      projects/models.py
  3. 13
      projects/templates/project_filter.html
  4. 42
      users/forms.py
  5. 31
      users/templates/contractor_filter.html
  6. 45
      users/views.py

@ -15,5 +15,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
for user in User.objects.all():
user.location = Location.objects.root_nodes()[0].get_descendants().order_by('?').first()
user.cro = _.sample((True, False))
user.save()

@ -20,6 +20,7 @@ TERMS = (
('month', 'За месяц'),
)
class BuildingClassfication(models.Model):
name = models.CharField(max_length=255)

@ -191,13 +191,16 @@
<p class="textPro">{{ proj.text }}</p>
{% if TEMPLATE_DEBUG %}
<pre class="textPro"><!--
<pre><!--
-->{{ proj|inspect }}<br><!--
--><br><!--
-->Specialization: {{ proj.specialization }}<br><!--
-->Realty location: {{ proj.realty.location }}<br><!--
-->Constr. type: {{ proj.realty.construction_type }}<br><!--
-->Build. classif.: {{ proj.realty.building_classification }}<br><!--
--><b>Specialization:</b> {{ proj.specialization }}<br><!--
--><br><!--
--><b>Realty location:</b> {{ proj.realty.location }}<br><!--
--><br><!--
--><b>Constr. type:</b> {{ proj.realty.construction_type }}<br><!--
--><br><!--
--><b>Build. classif.:</b> {{ proj.realty.building_classification }}<br><!--
--></pre>
{% endif %}

@ -1,9 +1,10 @@
from django import forms
from django.forms import ModelForm
import itertools
from .models import User, ContractorFinancialInfo
from common.models import Location
from projects.models import BuildingClassfication, ConstructionType
from projects.models import Project, BuildingClassfication, ConstructionType
from specializations.models import Specialization
@ -39,7 +40,7 @@ class UserEditForm(ModelForm):
}
class ContractorFilterForm(forms.ModelForm):
class ContractorFilterForm(forms.Form):
# PROJECT_ORDER_CHOICES = ( # "Упорядочить по"...
# ('name', 'названию'),
# ('budget', 'цене'),
@ -50,7 +51,6 @@ class ContractorFilterForm(forms.ModelForm):
# order_by = forms.ChoiceField(required=False, choices=PROJECT_ORDER_CHOICES)
# last_order_by = forms.ChoiceField(required=False, choices=PROJECT_ORDER_CHOICES)
# reverse_order = forms.BooleanField(required=False)
# keywords = forms.CharField(required=False, max_length=255)
specialization = forms.ModelChoiceField(
queryset=Specialization.objects.root_nodes()[0].get_descendants(),
@ -64,33 +64,29 @@ class ContractorFilterForm(forms.ModelForm):
building_classification = forms.ModelChoiceField(
queryset=BuildingClassfication.objects,
widget=forms.Select(attrs={'class': 'selectpicker'}),
required=False,
empty_label='',
)
class Meta:
model = User
fields = (
# 'cro',
# 'specialization',
# 'work_type',
)
# widgets = {
# 'work_type': forms.Select(attrs={'class': 'selectpicker'}),
# }
work_type = forms.ChoiceField(
choices=tuple(itertools.chain((('',''),), Project.WORK_TYPES)),
widget=forms.Select(attrs={'class': 'selectpicker'}),
required=False,
)
construction_type = forms.ModelChoiceField(
queryset=ConstructionType.objects,
widget=forms.Select(attrs={'class': 'selectpicker'}),
required=False,
empty_label='',
)
cro = forms.BooleanField(required=False)
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
# self.fields['work_type'].choices = tuple(itertools.chain((('',''),), self.fields['work_type'].choices))
# self.fields['work_type'].required = False
# self.fields['work_type'].initial = ''
#
# self.fields['specialization'].required = False
#
# self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants()
class ContractorFinancicalInfoForm(ModelForm):

@ -103,7 +103,8 @@
<div class="slideRes disTab activeSlide">
<div class="titleF1 disTab">
<div class="col-lg-3">Классификация здания</div>
{# <div class="col-lg-3">Вид строительства</div>#}
<div class="col-lg-3">Тип работы</div>
<div class="col-lg-3">Вид строительства</div>
</div>
<div class="polsF1 disTab">
@ -111,9 +112,18 @@
{{ form.building_classification }}
</div>
{# <div class="col-lg-3">#}
{# {{ realty_form.construction_type }}#}
{# </div>#}
<div class="col-lg-3">
{{ form.work_type }}
</div>
<div class="col-lg-3">
{{ form.construction_type }}
</div>
<div class="col-lg-3">
<label>{{ form.cro }}<span></span></label>
<p>Требуется допуск (СРО)</p>
</div>
</div>
</div>
@ -236,10 +246,17 @@
{% if TEMPLATE_DEBUG %}
<div class="col-lg-12">
<pre><!--
-->Specializations: {{ contractor.contractor_specializations.all }}<br><!--
--><b>Specializations:</b> {{ contractor.contractor_specializations.all }}<br><!--
--><br><!--
--><b>Location:</b> {{ contractor.location }}<br><!--
--><br><!--
--><b>Build. classif-s:</b> {% for o in contractor.orders.all %}{{ o.project.realty.building_classification }}, {% endfor %}<br><!--
--><br><!--
--><b>Constr. types:</b> {% for o in contractor.orders.all %}{{ o.project.realty.construction_type }}, {% endfor %}<br><!--
--><br><!--
--><b>CRO:</b> {{ contractor.cro }}<br><!--
--><br><!--
-->Location: {{ contractor.location }}<br><!--
-->Build. classif.: {% for o in contractor.orders.all %}{{ o.project.realty.building_classification }},{% endfor %}<br><!--
--><b>Work types:</b> {% for o in contractor.orders.all %}{{ o.project.work_type }}, {% endfor %}<br><!--
--></pre>
</div>
{% endif %}

@ -42,51 +42,39 @@ class ContractorFilterView(BaseMixin, View):
contractors = User.contractor_objects
if form.is_valid():
# keywords = form.cleaned_data.get('keywords')
# cro = form.cleaned_data.get('cro')
# work_type = form.cleaned_data.get('work_type')
cro = form.cleaned_data.get('cro')
specialization = form.cleaned_data.get('specialization')
# building_classification = realty_form.cleaned_data.get('building_classification')
# construction_type = realty_form.cleaned_data.get('construction_type')
location = form.cleaned_data.get('location')
work_type = form.cleaned_data.get('work_type')
build_classif = form.cleaned_data.get('building_classification')
constr_type = form.cleaned_data.get('construction_type')
# if keywords:
# keywords = tuple(filter(None, re.split(r'\s|,|;', keywords)))
#
# for k in keywords:
# projects = projects.filter(Q(name__icontains=k) | Q(text__icontains=k))
#
# projects = projects.filter(cro=cro)
#
# if work_type:
# projects = projects.filter(work_type=work_type)
contractors = contractors.filter(cro=cro)
if specialization:
contractors = contractors.filter(
# specialization__lft__gte=specialization.lft,
# specialization__rght__lte=specialization.rght,
contractor_specializations=specialization,
contractor_specializations=specialization, # TODO: Honor the hierarchical data structure
)
# if building_classification:
# projects = projects.filter(realty__building_classification=building_classification)
#
# if construction_type:
# projects = projects.filter(realty__construction_type=construction_type)
if location:
contractors = contractors.filter(
location__lft__gte=location.lft,
location__rght__lte=location.rght,
)
if work_type:
contractors = contractors.filter(orders__project__work_type=work_type).distinct() # TODO: OK?
if build_classif:
contractors = contractors.filter(orders__project__realty__building_classification=build_classif)
if constr_type:
contractors = contractors.filter(orders__project__realty__construction_type=constr_type)
# import code; code.interact(local=dict(globals(), **locals()))
# order_by = form.cleaned_data.get('order_by')
# last_order_by = form.cleaned_data.get('last_order_by')
@ -108,8 +96,6 @@ class ContractorFilterView(BaseMixin, View):
# 'reverse_order': reverse_order,
# })
# import code; code.interact(local=dict(globals(), **locals()))
contr_count = contractors.count()
display_msg = 'Найдено %s исполнителей' % contr_count if contr_count > 0 else 'Ничего не найдено'
else:
@ -120,12 +106,6 @@ class ContractorFilterView(BaseMixin, View):
'<p>Произошла ошибка (form)</p>'
'<pre>{form}</pre>'
).format(form=pformat(form.errors)))
# if realty_form and realty_form.errors:
# messages.info(request, (
# '<p>Произошла ошибка (realty_form)</p>'
# '<pre>{realty_form}</pre>'
# ).format(realty_form=pformat(realty_form.errors)))
paginator = Paginator(contractors.all(), settings.PAGE_SIZE)
@ -140,7 +120,6 @@ class ContractorFilterView(BaseMixin, View):
context.update({
'form': form,
# 'realty_form': realty_form,
'contractors': contractors,
'is_paginated': True,
'page_obj': contractors,

Loading…
Cancel
Save