From d255e1f89fdd58d162d736bc8ea18bd6eb2408fd Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Mon, 12 Oct 2020 23:03:33 +0100 Subject: [PATCH] First pass at clearer display of asset list filters --- assets/templates/asset_list.html | 54 +++++++++++++++++++++++++++++++- assets/views.py | 3 ++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/assets/templates/asset_list.html b/assets/templates/asset_list.html index d7e2e337..3a98e0b0 100644 --- a/assets/templates/asset_list.html +++ b/assets/templates/asset_list.html @@ -14,6 +14,48 @@ {% endblock %} +{% block js %} + +{% endblock %} + {% block content %}
@@ -40,8 +82,18 @@ {% button 'new' 'asset_create' style="width: 6em" %}
+
+
+ {# TODO Gotta be a cleaner way to do this... #} +

Active Filters: {% for filter in category_filters %}{{filter}}{%endfor%}{% for filter in status_filters %}{{filter}}{%endfor%}

+
+
-
+
{% include 'partials/asset_list_table.html' %}
diff --git a/assets/views.py b/assets/views.py index ccc26fa6..a7ebafc4 100644 --- a/assets/views.py +++ b/assets/views.py @@ -15,6 +15,7 @@ from django.views import generic from django.views.decorators.csrf import csrf_exempt from versioning import versioning from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin +from itertools import chain @method_decorator(csrf_exempt, name='dispatch') @@ -64,6 +65,8 @@ class AssetList(LoginRequiredMixin, generic.ListView): def get_context_data(self, **kwargs): context = super(AssetList, self).get_context_data(**kwargs) context["form"] = self.form + context["category_filters"] = self.form.cleaned_data['category'] + context["status_filters"] = self.form.cleaned_data['status'] context["categories"] = models.AssetCategory.objects.all() context["statuses"] = models.AssetStatus.objects.all() context["page_title"] = "Asset List"