From 520f5ad0d8a98939de9010c4508aa3459cdd6fee Mon Sep 17 00:00:00 2001 From: bkfox Date: Sun, 7 Aug 2022 10:48:31 +0200 Subject: [PATCH] fix date lookup filters --- aircox/admin/episode.py | 3 ++- aircox/admin/filters.py | 4 +++- aircox/locale/fr/LC_MESSAGES/django.po | 2 +- aircox/templates/admin/aircox/filters/date_filter.html | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/aircox/admin/episode.py b/aircox/admin/episode.py index cd688a4..e255cab 100644 --- a/aircox/admin/episode.py +++ b/aircox/admin/episode.py @@ -59,7 +59,8 @@ class EpisodeAdminForm(ModelForm): class EpisodeAdmin(PageAdmin): form = EpisodeAdminForm list_display = PageAdmin.list_display - list_filter = PageAdmin.list_filter + ('diffusion__start',) + list_filter = tuple(f for f in PageAdmin.list_filter if f != 'pub_date') + \ + ('diffusion__start', 'pub_date') search_fields = PageAdmin.search_fields + ('parent__title',) # readonly_fields = ('parent',) diff --git a/aircox/admin/filters.py b/aircox/admin/filters.py index ff70203..526ed5f 100644 --- a/aircox/admin/filters.py +++ b/aircox/admin/filters.py @@ -17,8 +17,10 @@ class DateFieldFilter(filters.FieldListFilter): self.date_params = {k: v for k, v in params.items() if k.startswith(self.field_generic)} + exact_lookup = 'date' if isinstance(field, models.DateTimeField) else 'exact' + # links as: (label, param, input_type|None, value) - self.links = [(_('Exact'), self.field_generic + 'exact', self.input_type), + self.links = [(_('Exact'), self.field_generic + exact_lookup, self.input_type), (_('Since'), self.field_generic + 'gte', self.input_type), (_('Until'), self.field_generic + 'lte', self.input_type)] if field.null: diff --git a/aircox/locale/fr/LC_MESSAGES/django.po b/aircox/locale/fr/LC_MESSAGES/django.po index 70354f6..493f73c 100644 --- a/aircox/locale/fr/LC_MESSAGES/django.po +++ b/aircox/locale/fr/LC_MESSAGES/django.po @@ -264,7 +264,7 @@ msgstr "catégorie" #: aircox/models/page.py:165 msgid "publication date" -msgstr "date de publications" +msgstr "date de publication" #: aircox/models/page.py:167 msgid "featured" diff --git a/aircox/templates/admin/aircox/filters/date_filter.html b/aircox/templates/admin/aircox/filters/date_filter.html index 2f55a2a..79c1d7e 100644 --- a/aircox/templates/admin/aircox/filters/date_filter.html +++ b/aircox/templates/admin/aircox/filters/date_filter.html @@ -10,9 +10,9 @@ onsubmit="return this.{{ choice.name }}.value ? true : false""> + value="{{ choice.value }}" {{ choice.extra }}/> {% for k, v in choice.query_attrs.items %} - + {% endfor %} -- 2.30.2