mirror of
https://github.com/django/django.git
synced 2025-10-05 00:00:37 +00:00
Fixed #20642 -- Deprecated Option.get_(add|change|delete)_permission
.
Those methods were only used by `contrib.admin` internally and exclusively related to `contrib.auth`. Since they were undocumented but used in the wild the raised deprecation warning point to an also undocumented alternative that lives in `contrib.auth`. Also did some PEP8 and other cleanups in the affected modules.
This commit is contained in:
parent
f819bef3dc
commit
b91787910c
5 changed files with 106 additions and 52 deletions
|
@ -414,12 +414,36 @@ class Options(object):
|
|||
return cache
|
||||
|
||||
def get_add_permission(self):
|
||||
"""
|
||||
This method has been deprecated in favor of
|
||||
`django.contrib.auth.get_permission_codename`. refs #20642
|
||||
"""
|
||||
warnings.warn(
|
||||
"`Options.get_add_permission` has been deprecated in favor "
|
||||
"of `django.contrib.auth.get_permission_codename`.",
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
return 'add_%s' % self.model_name
|
||||
|
||||
def get_change_permission(self):
|
||||
"""
|
||||
This method has been deprecated in favor of
|
||||
`django.contrib.auth.get_permission_codename`. refs #20642
|
||||
"""
|
||||
warnings.warn(
|
||||
"`Options.get_change_permission` has been deprecated in favor "
|
||||
"of `django.contrib.auth.get_permission_codename`.",
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
return 'change_%s' % self.model_name
|
||||
|
||||
def get_delete_permission(self):
|
||||
"""
|
||||
This method has been deprecated in favor of
|
||||
`django.contrib.auth.get_permission_codename`. refs #20642
|
||||
"""
|
||||
warnings.warn(
|
||||
"`Options.get_delete_permission` has been deprecated in favor "
|
||||
"of `django.contrib.auth.get_permission_codename`.",
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
return 'delete_%s' % self.model_name
|
||||
|
||||
def get_all_related_objects(self, local_only=False, include_hidden=False,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue