From 11cc227344de06ffd0ad7f07c4e4bdd18851adac Mon Sep 17 00:00:00 2001 From: Shubh1815 Date: Mon, 10 Jan 2022 19:04:24 +0530 Subject: [PATCH] Fixed #33267 -- Added link to related item to related widget wrapper in admin. --- .../admin/js/admin/RelatedObjectLookups.js | 4 ++-- .../admin/widgets/related_widget_wrapper.html | 10 ++++++++++ django/contrib/admin/widgets.py | 4 +++- docs/intro/_images/admin09.png | Bin 6719 -> 8120 bytes docs/releases/4.1.txt | 2 ++ tests/admin_widgets/tests.py | 13 +++++++++++++ 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js index 668c56a89d..284d44ad62 100644 --- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js @@ -125,7 +125,7 @@ this.textContent = newRepr; this.value = newId; } - }); + }).trigger('change'); selects.next().find('.select2-selection__rendered').each(function() { // The element can have a clear button as a child. // Use the lastChild to modify only the displayed value. @@ -178,7 +178,7 @@ event.preventDefault(); opener.dismissRelatedLookupPopup(window, $(this).data("popup-opener")); }); - $('body').on('click', '.related-widget-wrapper-link', function(e) { + $('body').on('click', '.related-widget-wrapper-link[data-popup="yes"]', function(e) { e.preventDefault(); if (this.href) { const event = $.Event('django:show-related', {href: this.href}); diff --git a/django/contrib/admin/templates/admin/widgets/related_widget_wrapper.html b/django/contrib/admin/templates/admin/widgets/related_widget_wrapper.html index a97bec16e3..9f7e586003 100644 --- a/django/contrib/admin/templates/admin/widgets/related_widget_wrapper.html +++ b/django/contrib/admin/templates/admin/widgets/related_widget_wrapper.html @@ -7,12 +7,14 @@ {% if can_change_related %} {% translate 'Change' %} {% endif %} {% if can_add_related %} {% translate 'Add' %} @@ -21,10 +23,18 @@ {% if can_delete_related %} {% translate 'Delete' %} {% endif %} + {% if can_view_related %} + + {% translate 'View' %} + + {% endif %} {% endif %} {% endspaceless %} {% endblock %} diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index c64c5d14f3..a361968b27 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -300,10 +300,11 @@ class RelatedFieldWidgetWrapper(forms.Widget): rel_opts = self.rel.model._meta info = (rel_opts.app_label, rel_opts.model_name) self.widget.choices = self.choices + related_field_name = self.rel.get_related_field().name url_params = "&".join( "%s=%s" % param for param in [ - (TO_FIELD_VAR, self.rel.get_related_field().name), + (TO_FIELD_VAR, related_field_name), (IS_POPUP_VAR, 1), ] ) @@ -325,6 +326,7 @@ class RelatedFieldWidgetWrapper(forms.Widget): info, "delete", "__fk__" ) if self.can_view_related or self.can_change_related: + context["view_related_url_params"] = f"{TO_FIELD_VAR}={related_field_name}" context["change_related_template_url"] = self.get_related_url( info, "change", "__fk__" ) diff --git a/docs/intro/_images/admin09.png b/docs/intro/_images/admin09.png index bfaeb3b99f694406287d92c6292ec7de3aeaeb92..7b649dc1d34434b920673e6728ea4d0916e49254 100644 GIT binary patch literal 8120 zcmZvB1yq~cwsn9|2$TZBid%4Z*U}Q4LUEVkPH`_32o$&C4#lB36iRU@?yjY{yT5Sm zf8RalzJFwlWPNLAuf4PP8gs5S15;L%#y}%N0{{RRGEgZM008kh0DyptiU{}g!mhah z0CGPWDT#OPb9<8r7ytkez+Ric$gJjk#C||a(Z#G_NSgT7K?;&1MGrGfRxCx4$L8SJ-kf3Y>u@?i5)^qgi!4|3a!{O1us1lpj+bpsIzm$S-Q zrIfTfWj?q@7a8t^mGR}sO)IgIf|aQ%XN&XJx|b-tQ)h9ee@$om&2zImA7OaEXeEW_ zC>N<2G_Cp}gDWk|gV+x3w<(4KO~THHE6m8KjMn};zGrb z>)-9mVcmxuXe6=f2|~1a1YMRQ)2r8M#ny|^*YF=lPNH5JI~iHNwkwDoP~hXhGyIMr zp;@s|btbXagX2x3j#2IX1sZWr7d?_Mm-GS@$RnUPql>4VGsBE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c^UZOd}b)XVc#q@!Wi}gDrpR;=;?hYLxr)UsSc^c>Z%f zUf7)vyF3lA@Af&!nofL))CK_}guni3I@44Icyvy&kiN8Y^NEE6uo4SKe#IrD+AYLw zg0UNEjr;xS+MwkGnuE~P1Ymz5W!OWr*$fJanoclydaevJv4dnJPJoo%THgmZjzK_T z(0{r^>K-~-eoa#ah^e`` is now paginated. +* Related widget wrappers now have a link to object's change form. + :mod:`django.contrib.admindocs` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index e291801cae..db724b4196 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -1675,6 +1675,7 @@ class AdminRawIdWidgetSeleniumTests(AdminWidgetSeleniumTestCase): class RelatedFieldWidgetSeleniumTests(AdminWidgetSeleniumTestCase): def test_ForeignKey_using_to_field(self): from selenium.webdriver.common.by import By + from selenium.webdriver.support.ui import Select self.admin_login(username="super", password="secret", login_url="/") self.selenium.get( @@ -1698,6 +1699,12 @@ class RelatedFieldWidgetSeleniumTests(AdminWidgetSeleniumTestCase): # The field now contains the new user self.selenium.find_element(By.CSS_SELECTOR, "#id_user option[value=newuser]") + self.selenium.find_element(By.ID, "view_id_user").click() + self.wait_for_value("#id_username", "newuser") + self.selenium.back() + + select = Select(self.selenium.find_element(By.ID, "id_user")) + select.select_by_value("newuser") # Click the Change User button to change it self.selenium.find_element(By.ID, "change_id_user").click() self.wait_for_and_switch_to_popup() @@ -1714,6 +1721,12 @@ class RelatedFieldWidgetSeleniumTests(AdminWidgetSeleniumTestCase): By.CSS_SELECTOR, "#id_user option[value=changednewuser]" ) + self.selenium.find_element(By.ID, "view_id_user").click() + self.wait_for_value("#id_username", "changednewuser") + self.selenium.back() + + select = Select(self.selenium.find_element(By.ID, "id_user")) + select.select_by_value("changednewuser") # Go ahead and submit the form to make sure it works self.selenium.find_element(By.CSS_SELECTOR, save_button_css_selector).click() self.wait_for_text(