Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated tests for deprecation of Option.get_(add|change|delete)_permi…

…ssion.

refs #20642.
  • Loading branch information...
commit a6a905c619e48bb3db4a5fbb09e5e03abb7ed0f6 1 parent cfcf4b3
Tim Graham authored July 01, 2013
3  django/contrib/admin/util.py
@@ -3,6 +3,7 @@
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
@@ -119,7 +120,7 @@ def format_callback(obj):
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.
15  tests/admin_views/tests.py
@@ -15,6 +15,7 @@
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
@@ -854,20 +855,20 @@ def setUp(self):
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 = {
@@ -1210,7 +1211,7 @@ def testConditionallyShowAddSectionLink(self):
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)
@@ -1315,7 +1316,7 @@ def setUp(self):
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 = {
@@ -1372,7 +1373,7 @@ def test_perms_needed(self):
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'))

0 notes on commit a6a905c

Please sign in to comment.
Something went wrong with that request. Please try again.