mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fix #1688 -- Output translatable labels when displaying permissions
This commit is contained in:
parent
e676f56527
commit
33878180d8
@ -77,7 +77,18 @@ class Permission(models.Model):
|
||||
ordering = ["content_type__app_label", "content_type__model", "codename"]
|
||||
|
||||
def __str__(self):
|
||||
return "%s | %s" % (self.content_type, self.name)
|
||||
names = {"content_type": self.content_type}
|
||||
|
||||
if self.name.startswith("Can add "):
|
||||
return _("%(content_type)s | Can add") % names
|
||||
if self.name.startswith("Can change "):
|
||||
return _("%(content_type)s | Can change") % names
|
||||
if self.name.startswith("Can delete "):
|
||||
return _("%(content_type)s | Can delete") % names
|
||||
if self.name.startswith("Can view "):
|
||||
return _("%(content_type)s | Can view") % names
|
||||
|
||||
return "%s | %s" % (self.content_type, _(self.name))
|
||||
|
||||
def natural_key(self):
|
||||
return (self.codename,) + self.content_type.natural_key()
|
||||
|
Loading…
Reference in New Issue
Block a user