Show not-None falsy values instead of blank in generic table cell template

stable/5.1.x
Sage Abdullah 2023-08-08 15:04:35 +01:00
rodzic 1890e8320d
commit dfc482e512
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
4 zmienionych plików z 19 dodań i 4 usunięć

Wyświetl plik

@ -1,3 +1,3 @@
<td {% if column.classname %}class="{{ column.classname }}"{% endif %}>
{% if value %}{{ value }}{% endif %}
{% if value is not None %}{{ value }}{% endif %}
</td>

Wyświetl plik

@ -666,6 +666,7 @@ class TestListViewWithCustomColumns(BaseSnippetViewSetTests):
self.assertContains(response, "Country code")
self.assertContains(response, "Custom FOO column")
self.assertContains(response, "Updated")
self.assertContains(response, "Modulo two")
self.assertContains(response, "Foo UK")
@ -677,8 +678,13 @@ class TestListViewWithCustomColumns(BaseSnippetViewSetTests):
html = response.content.decode()
# The bulk actions column plus 4 columns defined in FullFeaturedSnippetViewSet
self.assertTagInHTML("<th>", html, count=5, allow_extra_attrs=True)
# The bulk actions column plus 5 columns defined in FullFeaturedSnippetViewSet
self.assertTagInHTML("<th>", html, count=6, allow_extra_attrs=True)
def test_falsy_value(self):
# https://github.com/wagtail/wagtail/issues/10765
response = self.get()
self.assertContains(response, "<td>0</td>", html=True, count=1)
class TestListExport(BaseSnippetViewSetTests):

Wyświetl plik

@ -1128,6 +1128,9 @@ class FullFeaturedSnippet(
def __str__(self):
return self.text
def modulo_two(self):
return self.pk % 2
def get_preview_template(self, request, mode_name):
return "tests/previewable_model.html"

Wyświetl plik

@ -257,7 +257,13 @@ class FullFeaturedSnippetViewSet(SnippetViewSet):
list_per_page = 5
chooser_per_page = 15
filterset_class = FullFeaturedSnippetFilterSet
list_display = ["text", "country_code", "get_foo_country_code", UpdatedAtColumn()]
list_display = [
"text",
"country_code",
"get_foo_country_code",
UpdatedAtColumn(),
"modulo_two",
]
list_export = [
"text",
"country_code",