Poured a little more perfectionism into the delete-confirmation templates.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
93a4d46184
commit
53dac996ef
|
@ -52,9 +52,19 @@ def delete_selected(modeladmin, request, queryset):
|
||||||
# Return None to display the change list page again.
|
# Return None to display the change list page again.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if len(queryset) == 1:
|
||||||
|
objects_name = force_unicode(opts.verbose_name)
|
||||||
|
else:
|
||||||
|
objects_name = force_unicode(opts.verbose_name_plural)
|
||||||
|
|
||||||
|
if perms_needed or protected:
|
||||||
|
title = _("Cannot delete %(name)s") % {"name": objects_name}
|
||||||
|
else:
|
||||||
|
title = _("Are you sure?")
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"title": _("Are you sure?"),
|
"title": title,
|
||||||
"object_name": force_unicode(opts.verbose_name),
|
"objects_name": objects_name,
|
||||||
"deletable_objects": [deletable_objects],
|
"deletable_objects": [deletable_objects],
|
||||||
'queryset': queryset,
|
'queryset': queryset,
|
||||||
"perms_lacking": perms_needed,
|
"perms_lacking": perms_needed,
|
||||||
|
|
|
@ -1193,9 +1193,16 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
return HttpResponseRedirect("../../../../")
|
return HttpResponseRedirect("../../../../")
|
||||||
return HttpResponseRedirect("../../")
|
return HttpResponseRedirect("../../")
|
||||||
|
|
||||||
|
object_name = force_unicode(opts.verbose_name)
|
||||||
|
|
||||||
|
if perms_needed or protected:
|
||||||
|
title = _("Cannot delete %(name)s") % {"name": object_name}
|
||||||
|
else:
|
||||||
|
title = _("Are you sure?")
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"title": _("Are you sure?"),
|
"title": title,
|
||||||
"object_name": force_unicode(opts.verbose_name),
|
"object_name": object_name,
|
||||||
"object": obj,
|
"object": obj,
|
||||||
"deleted_objects": deleted_objects,
|
"deleted_objects": deleted_objects,
|
||||||
"perms_lacking": perms_needed,
|
"perms_lacking": perms_needed,
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if protected %}
|
{% if protected %}
|
||||||
<p>{% blocktrans with object as escaped_object %}Deleting the {{ object_name }} '{{ escaped_object }}' is not possible, because it would require deleting the following protected related objects:{% endblocktrans %}</p>
|
<p>{% blocktrans with object as escaped_object %}Deleting the {{ object_name }} '{{ escaped_object }}' would require deleting the following protected related objects:{% endblocktrans %}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for obj in protected %}
|
{% for obj in protected %}
|
||||||
<li>{{ obj }}</li>
|
<li>{{ obj }}</li>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if perms_lacking or protected %}
|
{% if perms_lacking or protected %}
|
||||||
{% if perms_lacking %}
|
{% if perms_lacking %}
|
||||||
<p>{% blocktrans %}Deleting the {{ object_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}</p>
|
<p>{% blocktrans %}Deleting the selected {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for obj in perms_lacking %}
|
{% for obj in perms_lacking %}
|
||||||
<li>{{ obj }}</li>
|
<li>{{ obj }}</li>
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if protected %}
|
{% if protected %}
|
||||||
<p>{% blocktrans %}Deleting the {{ object_name }} is not possible, because it would require deleting the following protected related objects:{% endblocktrans %}</p>
|
<p>{% blocktrans %}Deleting the selected {{ objects_name }} would require deleting the following protected related objects:{% endblocktrans %}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for obj in protected %}
|
{% for obj in protected %}
|
||||||
<li>{{ obj }}</li>
|
<li>{{ obj }}</li>
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>{% blocktrans %}Are you sure you want to delete the selected {{ object_name }} objects? All of the following objects and their related items will be deleted:{% endblocktrans %}</p>
|
<p>{% blocktrans %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktrans %}</p>
|
||||||
{% for deletable_object in deletable_objects %}
|
{% for deletable_object in deletable_objects %}
|
||||||
<ul>{{ deletable_object|unordered_list }}</ul>
|
<ul>{{ deletable_object|unordered_list }}</ul>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1632,7 +1632,7 @@ class AdminActionsTest(TestCase):
|
||||||
'post': 'yes',
|
'post': 'yes',
|
||||||
}
|
}
|
||||||
confirmation = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
|
confirmation = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
|
||||||
self.assertContains(confirmation, "Are you sure you want to delete the selected subscriber objects")
|
self.assertContains(confirmation, "Are you sure you want to delete the selected subscribers")
|
||||||
self.assertTrue(confirmation.content.count(ACTION_CHECKBOX_NAME) == 2)
|
self.assertTrue(confirmation.content.count(ACTION_CHECKBOX_NAME) == 2)
|
||||||
response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
|
response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
|
||||||
self.assertEqual(Subscriber.objects.count(), 0)
|
self.assertEqual(Subscriber.objects.count(), 0)
|
||||||
|
|
Loading…
Reference in New Issue