Fixed #7361 -- Added cancel link to admin delete views.

This commit is contained in:
Nick Sandford 2014-07-28 17:29:33 +01:00 committed by Tim Graham
parent a407b846b4
commit f5cfd09c25
4 changed files with 39 additions and 2 deletions

View File

@ -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;

View File

@ -37,6 +37,7 @@
<div>
<input type="hidden" name="post" value="yes" />
<input type="submit" value="{% trans "Yes, I'm sure" %}" />
<a href="#" onclick="window.history.back(); return false;" class="button cancel-link">{% trans "No, take me back" %}</a>
</div>
</form>
{% endif %}

View File

@ -42,6 +42,7 @@
<input type="hidden" name="action" value="delete_selected" />
<input type="hidden" name="post" value="yes" />
<input type="submit" value="{% trans "Yes, I'm sure" %}" />
<a href="#" onclick="window.history.back(); return false;" class="button cancel-link">{% trans "No, take me back" %}</a>
</div>
</form>
{% endif %}

View File

@ -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'