You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When it comes to filtering, we implement a class called DSLinkWidget which allows us to iterate over choices in the template layer. Currently, this is just implemented as and when we need it per-project, but it should be centralised in this dc_django_utils.
This code is currently used in WCIVF and YNR (probably some other projects too).
YNR doesn't currently use dc_django_utils so we won't be able to do the switcheroo there until we've got both of the projects integrated together
The DSLinkWidget code:
classDSLinkWidget(LinkWidget):
""" The LinkWidget doesn't allow iterating over choices in the template layer to change the HTML wrapping the widget. This breaks the way that Django *should* work, so we have to subclass and alter the HTML in Python :/ https://github.com/carltongibson/django-filter/issues/880 """defrender(self, name, value, attrs=None, choices=(), renderer=None):
ifnothasattr(self, "data"):
self.data= {}
ifvalueisNone:
value=""self.build_attrs(self.attrs, extra_attrs=attrs)
output= []
options=self.render_options(choices, [value], name)
ifoptions:
output.append(options)
# output.append('</ul>')returnmark_safe("\n".join(output))
defrender_option(self, name, selected_choices, option_value, option_label):
option_value=force_str(option_value)
ifoption_label==BLANK_CHOICE_DASH[0][1]:
option_label="All"data=self.data.copy()
data[name] =option_valueselected=data==self.dataoroption_valueinselected_choicestry:
url=data.urlencode()
exceptAttributeError:
url=urlencode(data)
returnself.option_string() % {
"attrs": selectedand' aria-current="true"'or"",
"query_string": url,
"label": force_str(option_label),
}
The text was updated successfully, but these errors were encountered:
When it comes to filtering, we implement a class called DSLinkWidget which allows us to iterate over choices in the template layer. Currently, this is just implemented as and when we need it per-project, but it should be centralised in this dc_django_utils.
This code is currently used in WCIVF and YNR (probably some other projects too).
YNR doesn't currently use dc_django_utils so we won't be able to do the switcheroo there until we've got both of the projects integrated together
The DSLinkWidget code:
The text was updated successfully, but these errors were encountered: