diff --git a/proposals/forms.py b/proposals/forms.py index 23ae9b4..ca44b7a 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -112,25 +112,32 @@ class SpeakerFilterForm(forms.Form): widget=forms.CheckboxSelectMultiple, choices=[], ) + track = forms.MultipleChoiceField( + required=False, + widget=forms.CheckboxSelectMultiple, + choices=[], + ) transport = forms.MultipleChoiceField( required=False, widget=forms.CheckboxSelectMultiple, - choices=[('unknown', 'Not answered')] + get_options(Transport), + choices=[('unanswered', 'Not answered'), ('unspecified', 'Not specified')] + get_options(Transport), ) + transport_booked = forms.NullBooleanField() accommodation= forms.MultipleChoiceField( required=False, widget=forms.CheckboxSelectMultiple, choices=[('unknown', 'Not specified')] + list(Participation.ACCOMMODATION_CHOICES), ) - sound = forms.NullBooleanField() - transport_booked = forms.NullBooleanField() accommodation_booked = forms.NullBooleanField() + sound = forms.NullBooleanField() def __init__(self, *args, **kwargs): site = kwargs.pop('site') super().__init__(*args, **kwargs) topics = Topic.objects.filter(site=site) self.fields['topic'].choices = topics.values_list('slug', 'name') + tracks = Track.objects.filter(site=site) + self.fields['track'].choices = [('none', 'Not assigned')] + list(tracks.values_list('slug', 'name')) class TopicForm(forms.ModelForm): diff --git a/proposals/templates/proposals/speaker_list.html b/proposals/templates/proposals/speaker_list.html index 800ebb0..97dd27b 100644 --- a/proposals/templates/proposals/speaker_list.html +++ b/proposals/templates/proposals/speaker_list.html @@ -19,14 +19,21 @@
{% 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" %} {% bootstrap_field filter_form.sound layout="horizontal" %} - {% bootstrap_field filter_form.status layout="horizontal" %}
+
+ {% bootstrap_field filter_form.accommodation layout="horizontal" %} + {% bootstrap_field filter_form.accommodation_booked layout="horizontal" %} + {% bootstrap_field filter_form.status layout="horizontal" %} +
+ +
{% bootstrap_field filter_form.topic layout="horizontal" %}
+
+ {% bootstrap_field filter_form.track layout="horizontal" %} +
diff --git a/proposals/views.py b/proposals/views.py index 9f268a7..1ac2a39 100644 --- a/proposals/views.py +++ b/proposals/views.py @@ -347,16 +347,27 @@ def speaker_list(request): if len(data['topic']): show_filters = True talks = talks.filter(reduce(lambda x, y: x | y, [Q(topics__slug=topic) for topic in data['topic']])) + if len(data['track']): + show_filters = True + q = Q() + if 'none' in data['track']: + data['track'].remove('none') + q |= Q(track__isnull=True) + if len(data['track']): + q |= Q(track__slug__in=data['track']) + talks = talks.filter(q) speakers = Participation.objects.filter(site=site,user__talk__in=talks).order_by('pk').distinct() if filter_form.is_valid(): data = filter_form.cleaned_data if len(data['transport']): show_filters = True q = Q() - if 'unknown' in data['transport']: - data['transport'].remove('unknown') - speakers = speakers.annotate(transport_count=Count('transport')) + if 'unanswered' in data['transport']: + data['transport'].remove('unanswered') q |= Q(need_transport=None) + if 'unspecified' in data['transport']: + data['transport'].remove('unspecified') + speakers = speakers.annotate(transport_count=Count('transport')) q |= Q(need_transport=True, transport_count=0) 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']])))