Opened 10 years ago

Closed 10 years ago

#24929 closed Cleanup/optimization (fixed)

permission_required decorator should take any iterable of permissions

Reported by: Raphael Michel Owned by: Raphael Michel
Component: contrib.auth Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Raphael Michel)

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 Raphael Michel, 10 years ago

Description: modified (diff)
Has patch: set
Owner: set to Raphael Michel
Status: newassigned
Summary: permission_required decorator should take any iterable if permissionspermission_required decorator should take any iterable of permissions

I created the pull request: https://github.com/django/django/pull/4790

comment:2 by Moritz Sichert, 10 years ago

Triage Stage: UnreviewedAccepted

Looks good!

comment:3 by Moritz Sichert, 10 years ago

Needs documentation: set

Although I think you should add some documentation for this change.

comment:4 by Marc Tamlyn, 10 years ago

Needs tests: set
Patch needs improvement: set

comment:5 by Raphael Michel, 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 Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 39937de7:

Fixed #24929 -- Allowed permission_required decorator to take any iterable

Note: See TracTickets for help on using tickets.
Back to Top