Opened 10 years ago
Closed 10 years ago
#24929 closed Cleanup/optimization (fixed)
permission_required decorator should take any iterable of permissions
Description (last modified by ) ¶
As it came up in the discussion on ticket #24914 on GitHub (https://github.com/django/django/pull/4749#discussion_r31776720), there is no reason why permission_required only takes lists and tuples of permissions, while has_perms
itself can take any iterable. To be consistent with the new mixins and other parts of Django where both strings and iterables of strings are accepted (see e.g. model._meta.ordering), we should change this logic. I will prepare a pull request with the same logic that is used in other places.
Change History (7)
comment:1 by , 10 years ago
Description: | modified (diff) |
---|---|
Has patch: | set |
Owner: | set to |
Status: | new → assigned |
Summary: | permission_required decorator should take any iterable if permissions → permission_required decorator should take any iterable of permissions |
comment:3 by , 10 years ago
Needs documentation: | set |
---|
Although I think you should add some documentation for this change.
comment:4 by , 10 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
comment:5 by , 10 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
I added a regression test and changed one word in the documentation (list → iterable). Do you expect more documentation on this? If so, how? I don't see a proper place (or a need for it).
comment:6 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
I created the pull request: https://github.com/django/django/pull/4790