Ticket #20642: 20642-tests.diff

File 20642-tests.diff, 3.9 KB (added by Tim Graham, 6 years ago)
  • django/contrib/admin/util.py

    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 
    33import datetime
    44import decimal
    55
     6from django.contrib.auth import get_permission_codename
    67from django.db import models
    78from django.db.models.constants import LOOKUP_SEP
    89from django.db.models.deletion import Collector
    def get_deleted_objects(objs, opts, user, admin_site, using): 
    119120                                   opts.model_name),
    120121                                None, (quote(obj._get_pk_val()),))
    121122            p = '%s.%s' % (opts.app_label,
    122                            opts.get_delete_permission())
     123                           get_permission_codename('delete', opts))
    123124            if not user.has_perm(p):
    124125                perms_needed.add(opts.verbose_name)
    125126            # Display a link to the admin page.
  • tests/admin_views/tests.py

    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 
    1515from django.core.urlresolvers import reverse
    1616# Register auth models with the admin.
    1717from django.contrib import admin
     18from django.contrib.auth import get_permission_codename
    1819from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
    1920from django.contrib.admin.models import LogEntry, DELETION
    2021from django.contrib.admin.sites import LOGIN_FORM_KEY
    class AdminViewPermissionsTest(TestCase): 
    854855        # User who can add Articles
    855856        add_user = User.objects.get(username='adduser')
    856857        add_user.user_permissions.add(get_perm(Article,
    857             opts.get_add_permission()))
     858            get_permission_codename('add', opts)))
    858859
    859860        # User who can change Articles
    860861        change_user = User.objects.get(username='changeuser')
    861862        change_user.user_permissions.add(get_perm(Article,
    862             opts.get_change_permission()))
     863            get_permission_codename('change', opts)))
    863864
    864865        # User who can delete Articles
    865866        delete_user = User.objects.get(username='deleteuser')
    866867        delete_user.user_permissions.add(get_perm(Article,
    867             opts.get_delete_permission()))
     868            get_permission_codename('delete', opts)))
    868869
    869870        delete_user.user_permissions.add(get_perm(Section,
    870             Section._meta.get_delete_permission()))
     871            get_permission_codename('delete', Section._meta)))
    871872
    872873        # login POST dicts
    873874        self.super_login = {
    class AdminViewPermissionsTest(TestCase): 
    12101211        # Allow the add user to add sections too. Now they can see the "add
    12111212        # section" link.
    12121213        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))
    12141215        add_user.user_permissions.add(perm)
    12151216        response = self.client.get(url)
    12161217        self.assertContains(response, add_link_text)
    class AdminViewsNoUrlTest(TestCase): 
    13151316        # User who can change Reports
    13161317        change_user = User.objects.get(username='changeuser')
    13171318        change_user.user_permissions.add(get_perm(Report,
    1318             opts.get_change_permission()))
     1319            get_permission_codename('change', opts)))
    13191320
    13201321        # login POST dict
    13211322        self.changeuser_login = {
    class AdminViewDeletedObjectsTest(TestCase): 
    13721373        self.client.logout()
    13731374        delete_user = User.objects.get(username='deleteuser')
    13741375        delete_user.user_permissions.add(get_perm(Plot,
    1375             Plot._meta.get_delete_permission()))
     1376            get_permission_codename('delete', Plot._meta)))
    13761377
    13771378        self.assertTrue(self.client.login(username='deleteuser',
    13781379                                          password='secret'))
Back to Top