diff --git a/django/contrib/admin/static/admin/css/base.css b/django/contrib/admin/static/admin/css/base.css index 3042ae0d62..47ac79b1d0 100644 --- a/django/contrib/admin/static/admin/css/base.css +++ b/django/contrib/admin/static/admin/css/base.css @@ -410,7 +410,7 @@ table.orderable-initalized .order-cell, body>tr>td.order-cell { /* FORM DEFAULTS */ -input, textarea, select, .form-row p { +input, textarea, select, .form-row p, form .button { margin: 2px 0; padding: 2px 3px; vertical-align: middle; @@ -430,7 +430,7 @@ textarea, select, .vTextField { /* FORM BUTTONS */ -.button, input[type=submit], input[type=button], .submit-row input { +.button, input[type=submit], input[type=button], .submit-row input, a.button { background: #fff url(../img/nav-bg.gif) bottom repeat-x; padding: 3px 5px; color: black; @@ -438,6 +438,10 @@ textarea, select, .vTextField { border-color: #ddd #aaa #aaa #ddd; } +a.button { + padding: 4px 5px; +} + .button:active, input[type=submit]:active, input[type=button]:active { background-image: url(../img/nav-bg-reverse.gif); background-position: top; diff --git a/django/contrib/admin/templates/admin/delete_confirmation.html b/django/contrib/admin/templates/admin/delete_confirmation.html index c3816408df..b2900ff4f1 100644 --- a/django/contrib/admin/templates/admin/delete_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_confirmation.html @@ -37,6 +37,7 @@
+ {% trans "No, take me back" %}
{% endif %} diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html index 154e779c49..8c8b8aa2f7 100644 --- a/django/contrib/admin/templates/admin/delete_selected_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_selected_confirmation.html @@ -42,6 +42,7 @@ + {% trans "No, take me back" %} {% endif %} diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 88539d4684..518e8fd7ba 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -3814,6 +3814,37 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase): self.selenium.find_element_by_id('id_start_date_0') ) + def test_cancel_delete_confirmation(self): + "Cancelling the deletion of an object takes the user back one page." + pizza = Pizza.objects.create(name="Panucci's Double Cheese") + url = reverse('admin:admin_views_pizza_change', args=(pizza.id,)) + full_url = '%s%s' % (self.live_server_url, url) + self.admin_login(username='super', password='secret', login_url='/test_admin/admin/') + self.selenium.get(full_url) + self.selenium.find_element_by_class_name('deletelink').click() + self.selenium.find_element_by_class_name('cancel-link').click() + self.assertEqual(self.selenium.current_url, full_url) + self.assertEqual(Pizza.objects.count(), 1) + + def test_cancel_delete_related_confirmation(self): + """ + Cancelling the deletion of an object with relations takes the user back + one page. + """ + pizza = Pizza.objects.create(name="Panucci's Double Cheese") + topping1 = Topping.objects.create(name="Cheddar") + topping2 = Topping.objects.create(name="Mozzarella") + pizza.toppings.add(topping1, topping2) + url = reverse('admin:admin_views_pizza_change', args=(pizza.id,)) + full_url = '%s%s' % (self.live_server_url, url) + self.admin_login(username='super', password='secret', login_url='/test_admin/admin/') + self.selenium.get(full_url) + self.selenium.find_element_by_class_name('deletelink').click() + self.selenium.find_element_by_class_name('cancel-link').click() + self.assertEqual(self.selenium.current_url, full_url) + self.assertEqual(Pizza.objects.count(), 1) + self.assertEqual(Topping.objects.count(), 2) + class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests): webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'