diff --git a/proposals/forms.py b/proposals/forms.py index ae52684..a918be2 100644 --- a/proposals/forms.py +++ b/proposals/forms.py @@ -55,6 +55,7 @@ class TalkFilterForm(forms.Form): widget=forms.CheckboxSelectMultiple, choices=[], ) + vote = forms.NullBooleanField(help_text='Filter topics you already / not yet voted for') def __init__(self, *args, **kwargs): site = kwargs.pop('site') diff --git a/proposals/templates/proposals/talk_list.html b/proposals/templates/proposals/talk_list.html index 87c9fca..350f08e 100644 --- a/proposals/templates/proposals/talk_list.html +++ b/proposals/templates/proposals/talk_list.html @@ -21,6 +21,7 @@
{% bootstrap_field filter_form.status layout="horizontal" %} + {% bootstrap_field filter_form.vote layout="horizontal" %}
{% bootstrap_field filter_form.topic layout="horizontal" %} diff --git a/proposals/views.py b/proposals/views.py index cf89b47..3423a07 100644 --- a/proposals/views.py +++ b/proposals/views.py @@ -77,6 +77,11 @@ def talk_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 data['vote'] != None: + if data['vote']: + talks = talks.filter(vote__user=request.user) + else: + talks = talks.exclude(vote__user=request.user) # Sorting if request.GET.get('order') == 'desc': reverse = True