Template improvements
* refactors templates/table.html into templates/generic_index.html * adds DummyFilterInput as do-not-render-widget * hardens combination of q filter and other filters on index view rendering
This commit is contained in:
@@ -11,20 +11,26 @@ from django.contrib.auth.models import User
|
||||
from django.db.models import QuerySet, Q
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from intervention.forms import DummyFilterInput
|
||||
from intervention.models import Intervention
|
||||
|
||||
|
||||
class InterventionTableFilter(django_filters.FilterSet):
|
||||
q = django_filters.Filter(
|
||||
method='_filter_by_keyword',
|
||||
widget=forms.HiddenInput(), # use search bar in template, we only need the filter logic in here!
|
||||
)
|
||||
sa = django_filters.BooleanFilter(
|
||||
method='_filter_show_all',
|
||||
label=_("Show unshared"),
|
||||
label_suffix=_(""),
|
||||
widget=forms.CheckboxInput()
|
||||
)
|
||||
q = django_filters.Filter(
|
||||
method='_filter_by_keyword',
|
||||
# Since we use a custom search bar in the template, we need to 'render' this filter
|
||||
# as 'anonymous' HiddenInput (no id, no name). This way our custom search bar's id and name won't be
|
||||
# overwritten with these id and name (which would be equal)
|
||||
# This way we can use the simple filter method mapping for a parameter without using a predefined widget!
|
||||
widget=DummyFilterInput(),
|
||||
)
|
||||
sr = django_filters.BooleanFilter(
|
||||
method='_filter_show_recorded',
|
||||
label=_("Show recorded"),
|
||||
|
||||
Reference in New Issue
Block a user