mirror of https://github.com/django/django.git
[1.6.x] Updated tests for deprecation of Option.get_(add|change|delete)_permission.
refs #20642.
Backport of a6a905c619
from master.
This commit is contained in:
parent
e03a88ba21
commit
3c51962cab
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
import datetime
|
||||
import decimal
|
||||
|
||||
from django.contrib.auth import get_permission_codename
|
||||
from django.db import models
|
||||
from django.db.models.constants import LOOKUP_SEP
|
||||
from django.db.models.deletion import Collector
|
||||
|
@ -119,7 +120,7 @@ def get_deleted_objects(objs, opts, user, admin_site, using):
|
|||
opts.model_name),
|
||||
None, (quote(obj._get_pk_val()),))
|
||||
p = '%s.%s' % (opts.app_label,
|
||||
opts.get_delete_permission())
|
||||
get_permission_codename('delete', opts))
|
||||
if not user.has_perm(p):
|
||||
perms_needed.add(opts.verbose_name)
|
||||
# Display a link to the admin page.
|
||||
|
|
|
@ -15,6 +15,7 @@ from django.core.files import temp as tempfile
|
|||
from django.core.urlresolvers import reverse
|
||||
# Register auth models with the admin.
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import get_permission_codename
|
||||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
|
||||
from django.contrib.admin.models import LogEntry, DELETION
|
||||
from django.contrib.admin.sites import LOGIN_FORM_KEY
|
||||
|
@ -854,20 +855,20 @@ class AdminViewPermissionsTest(TestCase):
|
|||
# User who can add Articles
|
||||
add_user = User.objects.get(username='adduser')
|
||||
add_user.user_permissions.add(get_perm(Article,
|
||||
opts.get_add_permission()))
|
||||
get_permission_codename('add', opts)))
|
||||
|
||||
# User who can change Articles
|
||||
change_user = User.objects.get(username='changeuser')
|
||||
change_user.user_permissions.add(get_perm(Article,
|
||||
opts.get_change_permission()))
|
||||
get_permission_codename('change', opts)))
|
||||
|
||||
# User who can delete Articles
|
||||
delete_user = User.objects.get(username='deleteuser')
|
||||
delete_user.user_permissions.add(get_perm(Article,
|
||||
opts.get_delete_permission()))
|
||||
get_permission_codename('delete', opts)))
|
||||
|
||||
delete_user.user_permissions.add(get_perm(Section,
|
||||
Section._meta.get_delete_permission()))
|
||||
get_permission_codename('delete', Section._meta)))
|
||||
|
||||
# login POST dicts
|
||||
self.super_login = {
|
||||
|
@ -1210,7 +1211,7 @@ class AdminViewPermissionsTest(TestCase):
|
|||
# Allow the add user to add sections too. Now they can see the "add
|
||||
# section" link.
|
||||
add_user = User.objects.get(username='adduser')
|
||||
perm = get_perm(Section, Section._meta.get_add_permission())
|
||||
perm = get_perm(Section, get_permission_codename('add', Section._meta))
|
||||
add_user.user_permissions.add(perm)
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, add_link_text)
|
||||
|
@ -1315,7 +1316,7 @@ class AdminViewsNoUrlTest(TestCase):
|
|||
# User who can change Reports
|
||||
change_user = User.objects.get(username='changeuser')
|
||||
change_user.user_permissions.add(get_perm(Report,
|
||||
opts.get_change_permission()))
|
||||
get_permission_codename('change', opts)))
|
||||
|
||||
# login POST dict
|
||||
self.changeuser_login = {
|
||||
|
@ -1372,7 +1373,7 @@ class AdminViewDeletedObjectsTest(TestCase):
|
|||
self.client.logout()
|
||||
delete_user = User.objects.get(username='deleteuser')
|
||||
delete_user.user_permissions.add(get_perm(Plot,
|
||||
Plot._meta.get_delete_permission()))
|
||||
get_permission_codename('delete', Plot._meta)))
|
||||
|
||||
self.assertTrue(self.client.login(username='deleteuser',
|
||||
password='secret'))
|
||||
|
|
Loading…
Reference in New Issue