Used model_ngettext in two more places
This commit is contained in:
parent
dbf79c5acf
commit
3b2e28fc85
|
@ -53,10 +53,7 @@ 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 = model_ngettext(queryset)
|
||||||
objects_name = force_text(opts.verbose_name)
|
|
||||||
else:
|
|
||||||
objects_name = force_text(opts.verbose_name_plural)
|
|
||||||
|
|
||||||
if perms_needed or protected:
|
if perms_needed or protected:
|
||||||
title = _("Cannot delete %(name)s") % {"name": objects_name}
|
title = _("Cannot delete %(name)s") % {"name": objects_name}
|
||||||
|
|
|
@ -16,8 +16,8 @@ from django.contrib.admin.exceptions import DisallowedModelAdminToField
|
||||||
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
|
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
|
||||||
from django.contrib.admin.utils import (
|
from django.contrib.admin.utils import (
|
||||||
NestedObjects, construct_change_message, flatten_fieldsets,
|
NestedObjects, construct_change_message, flatten_fieldsets,
|
||||||
get_deleted_objects, lookup_needs_distinct, model_format_dict, quote,
|
get_deleted_objects, lookup_needs_distinct, model_format_dict,
|
||||||
unquote,
|
model_ngettext, quote, unquote,
|
||||||
)
|
)
|
||||||
from django.contrib.auth import get_permission_codename
|
from django.contrib.auth import get_permission_codename
|
||||||
from django.core.exceptions import (
|
from django.core.exceptions import (
|
||||||
|
@ -1611,17 +1611,13 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
changecount += 1
|
changecount += 1
|
||||||
|
|
||||||
if changecount:
|
if changecount:
|
||||||
if changecount == 1:
|
|
||||||
name = force_text(opts.verbose_name)
|
|
||||||
else:
|
|
||||||
name = force_text(opts.verbose_name_plural)
|
|
||||||
msg = ungettext(
|
msg = ungettext(
|
||||||
"%(count)s %(name)s was changed successfully.",
|
"%(count)s %(name)s was changed successfully.",
|
||||||
"%(count)s %(name)s were changed successfully.",
|
"%(count)s %(name)s were changed successfully.",
|
||||||
changecount
|
changecount
|
||||||
) % {
|
) % {
|
||||||
'count': changecount,
|
'count': changecount,
|
||||||
'name': name,
|
'name': model_ngettext(opts, changecount),
|
||||||
'obj': force_text(obj),
|
'obj': force_text(obj),
|
||||||
}
|
}
|
||||||
self.message_user(request, msg, messages.SUCCESS)
|
self.message_user(request, msg, messages.SUCCESS)
|
||||||
|
|
Loading…
Reference in New Issue