filter topic by vote status
This commit is contained in:
parent
04d3dc99f4
commit
ba88c76b8a
|
@ -55,6 +55,7 @@ class TalkFilterForm(forms.Form):
|
||||||
widget=forms.CheckboxSelectMultiple,
|
widget=forms.CheckboxSelectMultiple,
|
||||||
choices=[],
|
choices=[],
|
||||||
)
|
)
|
||||||
|
vote = forms.NullBooleanField(help_text='Filter topics you already / not yet voted for')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
site = kwargs.pop('site')
|
site = kwargs.pop('site')
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 col-xs-6">
|
<div class="col-md-4 col-xs-6">
|
||||||
{% bootstrap_field filter_form.status layout="horizontal" %}
|
{% bootstrap_field filter_form.status layout="horizontal" %}
|
||||||
|
{% bootstrap_field filter_form.vote layout="horizontal" %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 col-xs-6">
|
<div class="col-md-4 col-xs-6">
|
||||||
{% bootstrap_field filter_form.topic layout="horizontal" %}
|
{% bootstrap_field filter_form.topic layout="horizontal" %}
|
||||||
|
|
|
@ -77,6 +77,11 @@ def talk_list(request):
|
||||||
if len(data['topic']):
|
if len(data['topic']):
|
||||||
show_filters = True
|
show_filters = True
|
||||||
talks = talks.filter(reduce(lambda x, y: x | y, [Q(topics__slug=topic) for topic in data['topic']]))
|
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
|
# Sorting
|
||||||
if request.GET.get('order') == 'desc':
|
if request.GET.get('order') == 'desc':
|
||||||
reverse = True
|
reverse = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user