kopia lustrzana https://github.com/wagtail/wagtail
Show not-None falsy values instead of blank in generic table cell template
rodzic
1890e8320d
commit
dfc482e512
|
@ -1,3 +1,3 @@
|
|||
<td {% if column.classname %}class="{{ column.classname }}"{% endif %}>
|
||||
{% if value %}{{ value }}{% endif %}
|
||||
{% if value is not None %}{{ value }}{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
Ładowanie…
Reference in New Issue