diff --git a/django/contrib/admin/util.py b/django/contrib/admin/util.py
index a53cd36..dd9047c 100644
a
|
b
|
from __future__ import unicode_literals
|
3 | 3 | import datetime |
4 | 4 | import decimal |
5 | 5 | |
| 6 | from django.contrib.auth import get_permission_codename |
6 | 7 | from django.db import models |
7 | 8 | from django.db.models.constants import LOOKUP_SEP |
8 | 9 | from django.db.models.deletion import Collector |
… |
… |
def get_deleted_objects(objs, opts, user, admin_site, using):
|
119 | 120 | opts.model_name), |
120 | 121 | None, (quote(obj._get_pk_val()),)) |
121 | 122 | p = '%s.%s' % (opts.app_label, |
122 | | opts.get_delete_permission()) |
| 123 | get_permission_codename('delete', opts)) |
123 | 124 | if not user.has_perm(p): |
124 | 125 | perms_needed.add(opts.verbose_name) |
125 | 126 | # Display a link to the admin page. |
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 235fe0c..1d63163 100644
a
|
b
|
from django.core.files import temp as tempfile
|
15 | 15 | from django.core.urlresolvers import reverse |
16 | 16 | # Register auth models with the admin. |
17 | 17 | from django.contrib import admin |
| 18 | from django.contrib.auth import get_permission_codename |
18 | 19 | from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME |
19 | 20 | from django.contrib.admin.models import LogEntry, DELETION |
20 | 21 | from django.contrib.admin.sites import LOGIN_FORM_KEY |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
854 | 855 | # User who can add Articles |
855 | 856 | add_user = User.objects.get(username='adduser') |
856 | 857 | add_user.user_permissions.add(get_perm(Article, |
857 | | opts.get_add_permission())) |
| 858 | get_permission_codename('add', opts))) |
858 | 859 | |
859 | 860 | # User who can change Articles |
860 | 861 | change_user = User.objects.get(username='changeuser') |
861 | 862 | change_user.user_permissions.add(get_perm(Article, |
862 | | opts.get_change_permission())) |
| 863 | get_permission_codename('change', opts))) |
863 | 864 | |
864 | 865 | # User who can delete Articles |
865 | 866 | delete_user = User.objects.get(username='deleteuser') |
866 | 867 | delete_user.user_permissions.add(get_perm(Article, |
867 | | opts.get_delete_permission())) |
| 868 | get_permission_codename('delete', opts))) |
868 | 869 | |
869 | 870 | delete_user.user_permissions.add(get_perm(Section, |
870 | | Section._meta.get_delete_permission())) |
| 871 | get_permission_codename('delete', Section._meta))) |
871 | 872 | |
872 | 873 | # login POST dicts |
873 | 874 | self.super_login = { |
… |
… |
class AdminViewPermissionsTest(TestCase):
|
1210 | 1211 | # Allow the add user to add sections too. Now they can see the "add |
1211 | 1212 | # section" link. |
1212 | 1213 | add_user = User.objects.get(username='adduser') |
1213 | | perm = get_perm(Section, Section._meta.get_add_permission()) |
| 1214 | perm = get_perm(Section, get_permission_codename('add', Section._meta)) |
1214 | 1215 | add_user.user_permissions.add(perm) |
1215 | 1216 | response = self.client.get(url) |
1216 | 1217 | self.assertContains(response, add_link_text) |
… |
… |
class AdminViewsNoUrlTest(TestCase):
|
1315 | 1316 | # User who can change Reports |
1316 | 1317 | change_user = User.objects.get(username='changeuser') |
1317 | 1318 | change_user.user_permissions.add(get_perm(Report, |
1318 | | opts.get_change_permission())) |
| 1319 | get_permission_codename('change', opts))) |
1319 | 1320 | |
1320 | 1321 | # login POST dict |
1321 | 1322 | self.changeuser_login = { |
… |
… |
class AdminViewDeletedObjectsTest(TestCase):
|
1372 | 1373 | self.client.logout() |
1373 | 1374 | delete_user = User.objects.get(username='deleteuser') |
1374 | 1375 | delete_user.user_permissions.add(get_perm(Plot, |
1375 | | Plot._meta.get_delete_permission())) |
| 1376 | get_permission_codename('delete', Plot._meta))) |
1376 | 1377 | |
1377 | 1378 | self.assertTrue(self.client.login(username='deleteuser', |
1378 | 1379 | password='secret')) |