#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
-------------------------------------+-------------------------------------
Changes (by pelletier):

 * cc: pelletier (added)
 * stage:  Unreviewed => Design decision needed


Comment:

 To my mind that's indeed an interesting feature, so I mark the ticket has
 DDN in order to get the opinion of a core developer.

 In addition, here two cents on your code:

 * I think this kind of code belongs to `UserManager`, so as we could do
 `User.objects.get_user_with_perm(...)` or something like that.
 * Having the "reverse" method on `Permission` objects could also be nice:
 `aperm.get_users()`.
 * Maybe instead of using a string to identify the permission (which is
 apparently not the natural key here) you should just take a Permission
 object and use it in the query. I think it would make the code clearer and
 also allow you to ensure the permission exists. Or the argument could be a
 natural key, then you retrieve and permission using
 `Permission.objcets.get_by_natural_key()` and use it in query.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18763#comment:2>
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