From: Jan Szejko Date: Mon, 24 Apr 2017 16:50:35 +0000 (+0200) Subject: prettier filtering for resources X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/3e85e1533d6109be1d5889fb98db7e3e07fedf72?hp=b2d61af6200bf8281e5466a183eae491440f4c1a prettier filtering for resources --- diff --git a/apps/catalogue/filters.py b/apps/catalogue/filters.py index e0069bba..e14864ba 100644 --- a/apps/catalogue/filters.py +++ b/apps/catalogue/filters.py @@ -4,6 +4,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # import django_filters +from django.forms.widgets import SelectMultiple from django.utils.functional import lazy from django_filters.filters import ModelMultipleChoiceFilter @@ -13,7 +14,13 @@ from catalogue.models import Document, Category def tag_filter(dc_tag): category = Category.objects.get(dc_tag=dc_tag) return ModelMultipleChoiceFilter( - queryset=category.tag_set.all(), label=lazy(lambda: category.label, unicode)(), method='filter_by_tag') + queryset=category.tag_set.all(), + label='', + widget=SelectMultiple(attrs={ + 'class': 'chosen-select', + 'data-placeholder': lazy(lambda: category.label, unicode)(), + }), + method='filter_by_tag') class DocumentFilterSet(django_filters.FilterSet): diff --git a/apps/catalogue/templates/catalogue/document_list_base.html b/apps/catalogue/templates/catalogue/document_list_base.html new file mode 100644 index 00000000..c896fa0d --- /dev/null +++ b/apps/catalogue/templates/catalogue/document_list_base.html @@ -0,0 +1,23 @@ +{% extends "catalogue/base.html" %} +{% load i18n %} + + +{% block content %} +
+

{% block header %}{% endblock %}

+
+
+
+

{% trans "Filters" %}

+
+ {{ filter_set.form.as_p }} + +
+
+
+ {% for doc in filter_set.qs %} + {% include "catalogue/resource_box.html" %} + {% endfor %} +
+
+{% endblock %} diff --git a/apps/catalogue/templates/catalogue/finished.html b/apps/catalogue/templates/catalogue/finished.html index 16188ccc..30adbacd 100644 --- a/apps/catalogue/templates/catalogue/finished.html +++ b/apps/catalogue/templates/catalogue/finished.html @@ -2,13 +2,4 @@ {% load i18n %} -{% block inner_content %} -

{% trans "Finished resources" %}

-
- {{ filter_set.form.as_p }} - -
- {% for doc in filter_set.qs %} - {% include "catalogue/resource_box.html" with link_url='catalogue_html' %} - {% endfor %} -{% endblock %} +{% block header %}{% trans "Finished resources" %}{% endblock %} diff --git a/apps/catalogue/templates/catalogue/upcoming.html b/apps/catalogue/templates/catalogue/upcoming.html index 1ac70456..ebddbfc4 100644 --- a/apps/catalogue/templates/catalogue/upcoming.html +++ b/apps/catalogue/templates/catalogue/upcoming.html @@ -1,14 +1,5 @@ -{% extends "catalogue/base.html" %} +{% extends "catalogue/document_list_base.html" %} {% load i18n %} -{% block inner_content %} -

{% trans "Upcoming resources" %}

-
- {{ filter_set.form.as_p }} - -
- {% for doc in filter_set.qs %} - {% include "catalogue/resource_box.html" with link_url='catalogue_preview' %} - {% endfor %} -{% endblock %} +{% block header %}{% trans "Upcoming resources" %}{% endblock %} diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 64e39f67..1f3130a0 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -514,6 +514,7 @@ def upcoming(request): f = DocumentFilterSet(request.GET, queryset=Document.objects.filter(deleted=False).filter(publish_log=None)) return render(request, "catalogue/upcoming.html", { 'filter_set': f, + 'link_url': 'catalogue_preview', }) @@ -521,4 +522,5 @@ def finished(request): f = DocumentFilterSet(request.GET, queryset=Document.objects.filter(deleted=False).exclude(publish_log=None)) return render(request, "catalogue/finished.html", { 'filter_set': f, + 'link_url': 'catalogue_html', })