diff --git a/aircox/filters.py b/aircox/filters.py index 39fa212..7b66b12 100644 --- a/aircox/filters.py +++ b/aircox/filters.py @@ -19,8 +19,14 @@ class PageFilters(filters.FilterSet): class EpisodeFilters(PageFilters): + podcast = filters.BooleanFilter(method='podcast_filter', label=_('Podcast')) + class Meta: model = Episode - fields = { - } + fields = PageFilters.Meta.fields.copy() + + def podcast_filter(self, queryset, name, value): + if value: + return queryset.filter(sound__is_public=True).distinct() + return queryset.filter(sound__isnull=True) diff --git a/aircox/templates/aircox/base.html b/aircox/templates/aircox/base.html index 955e801..7412b83 100644 --- a/aircox/templates/aircox/base.html +++ b/aircox/templates/aircox/base.html @@ -57,6 +57,8 @@ Usefull context: {% endblock %}
diff --git a/aircox/templates/aircox/page_list.html b/aircox/templates/aircox/page_list.html index 1d1945e..f23de90 100644 --- a/aircox/templates/aircox/page_list.html +++ b/aircox/templates/aircox/page_list.html @@ -5,7 +5,7 @@ {% block before_list %} {{ block.super }} -{% if view.has_filters %} +{% if view.has_filters and object_list %}