#18763: Shortcut to get users by permission
-------------------------------------+-------------------------------------
     Reporter:  shelldweller         |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  contrib.auth         |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Design
    Has patch:  0                    |  decision needed
  Needs tests:  0                    |      Needs documentation:  0
Easy pickings:  0                    |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by leckey.ryan@…):

 I would propose `for_perm` and `for_perms` methods on both the user and
 the default object manager.

 So statements like the following could happen:

 {{{#!python
 user.for_perm('foo.bar')     # Queryset of users that have that permission
 user.for_perm('foo.bar', o)  # Queryset of users that have that permission
 for

 Poll.objects.for_perm(user, 'foo.bar')   # Queryset of all Polls where the
 user has the permission for

 # .. `for_perms` would be much the same except with an iterable for
 permission names like `has_perms`
 }}}

 Of course this should be hooked through the permission backend and not
 special-cased for Permission objects.

 I could write a patch to add the for_perm and for_perms hooks as well as
 implementation for the ModelBackend if the above sounds fine. Thought
 about this for awhile now. Thoughts?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18763#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to