2 Commits

Author SHA1 Message Date
2c58bc955f Fixed bad template referencing in filters.py. 2023-09-03 08:25:12 +03:00
75e9a60b87 Added the missing templates. 2023-09-03 08:04:58 +03:00
4 changed files with 52 additions and 3 deletions

View File

@@ -89,7 +89,7 @@ class CategoryFilter(BaseFilterBackend):
"""
This filter assigns the view.category object for later use, in particular for filters that depend on this one.
"""
template = './filters/categories.html'
template = 'starfields_drf_generics/filters/categories.html'
category_field = 'category'
def get_category_class(self, view, request):
@@ -203,7 +203,7 @@ class FacetFilter(BaseFilterBackend):
"""
This filter requires CategoryFilter to be ran before it. It assigns the view.facets which includes all the facets applicable to the current category.
"""
template = './filters/facets.html'
template = 'starfields_drf_generics/filters/facets.html'
def get_facet_class(self, view, request):
return getattr(view, 'facet_class', None)
@@ -423,7 +423,7 @@ class TrigramSearchFilter(BaseFilterBackend):
# TODO misunderstood the urlconf stuff of the RUD methods, this is probably unnecessary
class SlugSearchFilter(BaseFilterBackend):
# The URL query parameter used for the search.
template = './filters/slug.html'
template = 'starfields_drf_generics/filters/slug.html'
slug_title = _('Slug Search')
slug_description = _("The instance's slug.")
slug_field = 'slug'

View File

@@ -0,0 +1,14 @@
{% load rest_framework %}
{% load i18n %}
<h2>{% trans "Categories" %}</h2>
<div class="list-group">
{% for key, label in options %}
{% if key == current %}
<a href="{% add_query_param request param key %}" class="list-group-item active">
<span class="glyphicon glyphicon-ok" style="float: right" aria-hidden="true"></span> {{ label }}
</a>
{% else %}
<a href="{% add_query_param request param key %}" class="list-group-item">{{ label }}</a>
{% endif %}
{% endfor %}
</div>

View File

@@ -0,0 +1,23 @@
{% load rest_framework %}
{% load i18n %}
<h2>{% trans "Facets" %}</h2>
{% for facet_tag_slug_key, facet_tag_slug_values in options.items %}
{% for facet_slug, facet_name in facet_slug_names.items %}
{% if facet_slug == facet_tag_slug_key %}
<h3>{{ facet_name }}</h3>
{% endif %}
{% endfor %}
<div class="list-group">
{% for tag_slug in facet_tag_slug_values %}
{% if tag_slug.0 in current %}
{# TODO this does not remove parameters #}
<a href="{% add_query_param request facet_tag_slug_key tag_slug.0 %}" class="list-group-item active">
<span class="glyphicon glyphicon-ok" style="float: right" aria-hidden="true"></span> {{ tag_slug.1 }}
</a>
{% else %}
<a href="{% add_query_param request facet_tag_slug_key tag_slug.0 %}" class="list-group-item">{{ tag_slug.1 }}</a>
{% endif %}
{% endfor %}
</div>
{% endfor %}

View File

@@ -0,0 +1,12 @@
{% load i18n %}
<h2>{% trans "Slug" %}</h2>
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" style="width: 350px" name="{{ param }}" value="{{ term }}">
<span class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> {% trans "Slug" %}</button>
</span>
</div>
</div>
</form>