Filter projects by realty

remotes/origin/PR-39
ArturBaybulatov 9 years ago
parent c72d66be97
commit 6141fdf9b1
  1. 4
      projects/forms.py
  2. 5
      projects/serializers.py
  3. 2
      projects/templates/project_filter.html
  4. 4
      projects/views.py

@ -35,8 +35,10 @@ class ProjectFilterForm(forms.ModelForm):
fields = (
'cro',
'specialization',
'work_type',
'realty',
'specialization',
)
widgets = {

@ -67,11 +67,12 @@ class RealtySerializer(ModelSerializer):
model = Realty
fields = (
'id',
'name',
'building_classification',
'construction_type',
'id',
'location',
'name',
'user',
)

@ -185,7 +185,7 @@
{% if project.realty and project.realty.name %}
<ul class="desPro">
<li>
Объект "{{ project.realty.name }}"
<a href="?realty={{ project.realty.pk }}">Объект "{{ project.realty.name }}"</a>
</li>
</ul>
{% endif %}

@ -288,6 +288,7 @@ class ProjectFilterView(BaseMixin, View):
cro = form.cleaned_data.get('cro')
work_type = form.cleaned_data.get('work_type')
specialization = form.cleaned_data.get('specialization')
realty = form.cleaned_data.get('realty')
building_classification = realty_form.cleaned_data.get('building_classification')
construction_type = realty_form.cleaned_data.get('construction_type')
@ -322,6 +323,9 @@ class ProjectFilterView(BaseMixin, View):
realty__location__lft__gte=location.lft,
realty__location__rght__lte=location.rght,
)
if realty:
projects = projects.filter(realty=realty)
order_by = form.cleaned_data.get('order_by')
last_order_by = form.cleaned_data.get('last_order_by')

Loading…
Cancel
Save