kopia lustrzana https://github.com/wagtail/wagtail
Ensure thumb_col_header_text is used by ThumbnailMixin correctly
- fixes #8269 because you cannot dynamically set attributes on bound methods, we need to update the current classes version of admin_thumb so it can be accessed in sub classespull/8305/head
rodzic
0b8a8c2024
commit
844efa696a
|
@ -58,6 +58,7 @@ Changelog
|
|||
* Fix: Stop skipping heading levels in Wagtail welcome page (Jesse Menn)
|
||||
* Fix: Add missing `lang` attributes to `<html>` elements (James Ray)
|
||||
* Fix: Avoid 503 server error when entering tags over 100chars and instead show a user facing validation error (Vu Pham, Khanh Hoang)
|
||||
* Fix: Ensure `thumb_col_header_text` is correctly used by `ThumbnailMixin` within `ModelAdmin` as the column header label (Kyle J. Roux)
|
||||
|
||||
|
||||
2.16.2 (xx.xx.xxxx) - IN DEVELOPMENT
|
||||
|
|
|
@ -588,6 +588,7 @@ Contributors
|
|||
* Caio Jhonny
|
||||
* Heather White
|
||||
* Onno Timmerman
|
||||
* Kyle J. Roux
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -93,6 +93,7 @@ class LandingPage(Page):
|
|||
* Add missing `lang` attributes to `<html>` elements (James Ray)
|
||||
* Add missing translation usage in Workflow templates (Anuja Verma, Saurabh Kumar)
|
||||
* Avoid 503 server error when entering tags over 100chars and instead show a user facing validation error (Vu Pham, Khanh Hoang)
|
||||
* Ensure `thumb_col_header_text` is correctly used by `ThumbnailMixin` within `ModelAdmin` as the column header label (Kyle J. Roux)
|
||||
|
||||
|
||||
## Upgrade considerations
|
||||
|
|
|
@ -25,6 +25,7 @@ class ThumbnailMixin:
|
|||
"The `wagtail.images` app must be installed in order "
|
||||
"to use the `ThumbnailMixin` class."
|
||||
)
|
||||
self.__class__.admin_thumb.short_description = self.thumb_col_header_text
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def admin_thumb(self, obj):
|
||||
|
@ -53,5 +54,3 @@ class ThumbnailMixin:
|
|||
rendition = get_rendition_or_not_found(image, spec)
|
||||
img_attrs.update({"src": rendition.url})
|
||||
return mark_safe("<img{}>".format(flatatt(img_attrs)))
|
||||
|
||||
admin_thumb.short_description = thumb_col_header_text
|
||||
|
|
|
@ -43,6 +43,16 @@ class TestBookIndexView(TestCase, WagtailTestUtils):
|
|||
def get(self, **params):
|
||||
return self.client.get("/admin/modeladmintest/book/", params)
|
||||
|
||||
def test_thumbnail_image_col_header_text(self):
|
||||
response = self.get()
|
||||
|
||||
# check thumb_col_header_text is correctly used
|
||||
self.assertContains(
|
||||
response,
|
||||
'<th scope="col" class="column-admin_thumb">The cover</th>',
|
||||
html=True,
|
||||
)
|
||||
|
||||
def test_simple(self):
|
||||
response = self.get()
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ class BookModelAdmin(ThumbnailMixin, ModelAdmin):
|
|||
inspect_view_enabled = True
|
||||
inspect_view_fields_exclude = ("title",)
|
||||
thumb_image_field_name = "cover_image"
|
||||
thumb_col_header_text = "The cover"
|
||||
search_handler_class = WagtailBackendSearchHandler
|
||||
prepopulated_fields = {"title": ("author",)}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue