filter speakers that did not answered transport
This commit is contained in:
parent
848aef170a
commit
65d23ddc25
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10 on 2016-10-13 16:45
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('planning', '0003_room_label'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='room',
|
||||
options={'ordering': ['name']},
|
||||
),
|
||||
]
|
|
@ -115,7 +115,7 @@ class SpeakerFilterForm(forms.Form):
|
|||
transport = forms.MultipleChoiceField(
|
||||
required=False,
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
choices=get_options(Transport),
|
||||
choices=[('unknown', 'Not answered')] + get_options(Transport),
|
||||
)
|
||||
accommodation= forms.MultipleChoiceField(
|
||||
required=False,
|
||||
|
|
|
@ -16,17 +16,15 @@
|
|||
<div class="well">
|
||||
<form class="form-horizontal" method="get">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-xs-6">
|
||||
<div class="col-md-6">
|
||||
{% bootstrap_field filter_form.transport layout="horizontal" %}
|
||||
{% bootstrap_field filter_form.transport_booked layout="horizontal" %}
|
||||
{% bootstrap_field filter_form.accommodation layout="horizontal" %}
|
||||
{% bootstrap_field filter_form.accommodation_booked layout="horizontal" %}
|
||||
</div>
|
||||
<div class="col-md-4 col-xs-6">
|
||||
{% bootstrap_field filter_form.sound layout="horizontal" %}
|
||||
{% bootstrap_field filter_form.status layout="horizontal" %}
|
||||
</div>
|
||||
<div class="col-md-4 col-xs-6">
|
||||
<div class="col-md-6">
|
||||
{% bootstrap_field filter_form.topic layout="horizontal" %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -352,7 +352,13 @@ def speaker_list(request):
|
|||
data = filter_form.cleaned_data
|
||||
if len(data['transport']):
|
||||
show_filters = True
|
||||
speakers = speakers.filter(need_transport=True).filter(reduce(lambda x, y: x | y, [Q(transport__pk=pk) for pk in data['transport']]))
|
||||
q = Q()
|
||||
if 'unknown' in data['transport']:
|
||||
data['transport'].remove('unknown')
|
||||
q |= Q(need_transport=None)
|
||||
if len(data['transport']):
|
||||
q |= (Q(need_transport=True) & Q(reduce(lambda x, y: x | y, [Q(transport__pk=pk) for pk in data['transport']])))
|
||||
speakers = speakers.filter(q)
|
||||
if len(data['accommodation']):
|
||||
show_filters = True
|
||||
accommodations = list(map(lambda x: None if x == 'unknown' else x, data['accommodation']))
|
||||
|
|
Loading…
Reference in New Issue