filter talk by room and schedule status

This commit is contained in:
Élie Bouttier 2016-10-11 22:37:40 +02:00
parent d4c24cf35e
commit 5a97705cc9
3 changed files with 9 additions and 1 deletions

View File

@ -60,6 +60,8 @@ class TalkFilterForm(forms.Form):
choices=[],
)
vote = forms.NullBooleanField(help_text=_('Filter talks you already / not yet voted for'))
room = forms.NullBooleanField(help_text=_('Filter talks already / not yet affected to a room'))
scheduled = forms.NullBooleanField(help_text=_('Filter talks already / not yet scheduled'))
def __init__(self, *args, **kwargs):
site = kwargs.pop('site')

View File

@ -18,8 +18,10 @@
<div class="row">
<div class="col-md-4 col-xs-6">
{% bootstrap_field filter_form.status layout="horizontal" %}
{% bootstrap_field filter_form.vote layout="horizontal" %}
{% bootstrap_field filter_form.kind layout="horizontal" %}
{% bootstrap_field filter_form.vote layout="horizontal" %}
{% bootstrap_field filter_form.room layout="horizontal" %}
{% bootstrap_field filter_form.scheduled layout="horizontal" %}
</div>
<div class="col-md-4 col-xs-6">
{% bootstrap_field filter_form.topic layout="horizontal" %}

View File

@ -96,6 +96,10 @@ def talk_list(request):
talks = talks.filter(vote__user=request.user)
else:
talks = talks.exclude(vote__user=request.user)
if data['room'] != None:
talks = talks.filter(room__isnull=not data['room'])
if data['scheduled'] != None:
talks = talks.filter(start_date__isnull=not data['scheduled'])
# Sorting
if request.GET.get('order') == 'desc':
reverse = True