From 81d23fc8ab28486d79fc87a0ef730c4ba6e2907c Mon Sep 17 00:00:00 2001 From: Andy Chosak Date: Fri, 24 Jan 2020 13:57:02 -0500 Subject: [PATCH] Support the rel attribute on ModelAdmin buttons Currently it is possible to pass the target attribute to a button created using ModelAdmin's ButtonHelper framework. This allows you to generate button links like . For example, if adding a new button and modeling it after the existing edit_button code [0], you can add {'target': "_blank"} to the returned dict and it'll get passed to the template when the button is rendered. To be consistent with PR 4844, and to be consistent with what seems to be the best practice ([1], [2]), we should also support passing the rel attribute, which would allow for creation of button links like . [0] https://github.com/wagtail/wagtail/blob/5e2f50403b093b651f19852e3cd1b4835b3b5125/wagtail/contrib/modeladmin/helpers/button.py#L61-L73 [1] https://developers.google.com/web/tools/lighthouse/audits/noopener [2] https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/ --- CHANGELOG.txt | 1 + docs/releases/2.9.rst | 1 + .../modeladmin/templates/modeladmin/includes/button.html | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a7b206ded..3b1833e75 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -10,6 +10,7 @@ Changelog * Fix: Re-add 'Close Explorer' button on mobile viewports (Sævar Öfjörð Magnússon) * Fix: Add a more descriptive label to Password reset link for screen reader users (Casper Timmers, Martin Coote) * Fix: Improve Wagtail logo contrast by adding a background (Brian Edelman, Simon Evans, Ben Enright) + * Support the rel attribute on custom ModelAdmin buttons (Andy Chosak) 2.8 (xx.xx.xxxx) - IN DEVELOPMENT diff --git a/docs/releases/2.9.rst b/docs/releases/2.9.rst index 602b44799..1fa1607df 100644 --- a/docs/releases/2.9.rst +++ b/docs/releases/2.9.rst @@ -15,6 +15,7 @@ Other features ~~~~~~~~~~~~~~ * Reduced contrast of rich text toolbar (Jack Paine) + * Support the rel attribute on custom ModelAdmin buttons (Andy Chosak) Bug fixes diff --git a/wagtail/contrib/modeladmin/templates/modeladmin/includes/button.html b/wagtail/contrib/modeladmin/templates/modeladmin/includes/button.html index eabc958cd..67854d728 100644 --- a/wagtail/contrib/modeladmin/templates/modeladmin/includes/button.html +++ b/wagtail/contrib/modeladmin/templates/modeladmin/includes/button.html @@ -1 +1 @@ -{{ button.label }} +{{ button.label }}