diff --git a/archilance/management/commands/tmp.py b/archilance/management/commands/tmp.py index 1258132..fcda9a3 100644 --- a/archilance/management/commands/tmp.py +++ b/archilance/management/commands/tmp.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() diff --git a/projects/models.py b/projects/models.py index 24e5e3f..d9935b4 100644 --- a/projects/models.py +++ b/projects/models.py @@ -20,6 +20,7 @@ TERMS = ( ('month', 'За месяц'), ) + class BuildingClassfication(models.Model): name = models.CharField(max_length=255) diff --git a/projects/templates/project_filter.html b/projects/templates/project_filter.html index 66589db..af9148e 100644 --- a/projects/templates/project_filter.html +++ b/projects/templates/project_filter.html @@ -191,13 +191,16 @@
{{ proj.text }}
{% if TEMPLATE_DEBUG %} -{{ proj|inspect }}
Specialization: {{ proj.specialization }}
Realty location: {{ proj.realty.location }}
Constr. type: {{ proj.realty.construction_type }}
Build. classif.: {{ proj.realty.building_classification }}
Specialization: {{ proj.specialization }}
Realty location: {{ proj.realty.location }}
Constr. type: {{ proj.realty.construction_type }}
Build. classif.: {{ proj.realty.building_classification }}
{% endif %}
diff --git a/users/forms.py b/users/forms.py
index 55d625e..9970216 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -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):
diff --git a/users/templates/contractor_filter.html b/users/templates/contractor_filter.html
index 1c26209..2c20381 100644
--- a/users/templates/contractor_filter.html
+++ b/users/templates/contractor_filter.html
@@ -103,7 +103,8 @@
@@ -236,10 +246,17 @@
{% if TEMPLATE_DEBUG %}
Specializations: {{ contractor.contractor_specializations.all }}
Specializations: {{ contractor.contractor_specializations.all }}
Location: {{ contractor.location }}
Build. classif-s: {% for o in contractor.orders.all %}{{ o.project.realty.building_classification }}, {% endfor %}
Constr. types: {% for o in contractor.orders.all %}{{ o.project.realty.construction_type }}, {% endfor %}
CRO: {{ contractor.cro }}
Location: {{ contractor.location }}
Build. classif.: {% for o in contractor.orders.all %}{{ o.project.realty.building_classification }},{% endfor %}
Work types: {% for o in contractor.orders.all %}{{ o.project.work_type }}, {% endfor %}
Произошла ошибка (form)
' '{form}'
).format(form=pformat(form.errors)))
-
- # if realty_form and realty_form.errors:
- # messages.info(request, (
- # 'Произошла ошибка (realty_form)
' - # '{realty_form}'
- # ).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,