Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Poured a little more perfectionism into the delete-confirmation templ…

…ates.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 53dac996efedf9138938ad4aa5647cb68006937c 1 parent 93a4d46
@carljm carljm authored
View
14 django/contrib/admin/actions.py
@@ -52,9 +52,19 @@ def delete_selected(modeladmin, request, queryset):
# Return None to display the change list page again.
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 = {
- "title": _("Are you sure?"),
- "object_name": force_unicode(opts.verbose_name),
+ "title": title,
+ "objects_name": objects_name,
"deletable_objects": [deletable_objects],
'queryset': queryset,
"perms_lacking": perms_needed,
View
11 django/contrib/admin/options.py
@@ -1193,9 +1193,16 @@ def delete_view(self, request, object_id, extra_context=None):
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 = {
- "title": _("Are you sure?"),
- "object_name": force_unicode(opts.verbose_name),
+ "title": title,
+ "object_name": object_name,
"object": obj,
"deleted_objects": deleted_objects,
"perms_lacking": perms_needed,
View
2  django/contrib/admin/templates/admin/delete_confirmation.html
@@ -22,7 +22,7 @@
</ul>
{% endif %}
{% 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>
{% for obj in protected %}
<li>{{ obj }}</li>
View
6 django/contrib/admin/templates/admin/delete_selected_confirmation.html
@@ -13,7 +13,7 @@
{% block content %}
{% if perms_lacking or protected %}
{% 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>
{% for obj in perms_lacking %}
<li>{{ obj }}</li>
@@ -21,7 +21,7 @@
</ul>
{% endif %}
{% 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>
{% for obj in protected %}
<li>{{ obj }}</li>
@@ -29,7 +29,7 @@
</ul>
{% endif %}
{% 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 %}
<ul>{{ deletable_object|unordered_list }}</ul>
{% endfor %}
View
2  tests/regressiontests/admin_views/tests.py
@@ -1632,7 +1632,7 @@ def test_model_admin_default_delete_action(self):
'post': 'yes',
}
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)
response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
self.assertEqual(Subscriber.objects.count(), 0)
Please sign in to comment.
Something went wrong with that request. Please try again.