Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shorthand to visible_to helper #5

Open
daisylb opened this issue Mar 23, 2018 · 0 comments
Open

Add shorthand to visible_to helper #5

daisylb opened this issue Mar 23, 2018 · 0 comments

Comments

@daisylb
Copy link
Owner

daisylb commented Mar 23, 2018

Currently, calls to visible_to look like this:

Shrubbery.objects.visible_to(user, 'shrubberies.change_shrubbery')

I'd like to change the signature to visible_to(user, *, using, action), so that the above call looks like one of the following:

Shrubbery.objects.visible_to(user, using='shrubberies.change_shrubbery')
Shrubbery.objects.visible_to(user, action='change')

We could even go further for the three conventional actions for which it makes sense to filter QuerySets:

Shrubbery.objects.viewable_by(user)
Shrubbery.objects.changeable_by(user)
Shrubbery.objects.deleteable_by(user)

The permission used by the short forms would be looked up in the registry in much the same way as it already is, but the name to look up would be autogenerated in much the same way that the Django REST Framework integration works, by extracting the app and model name from the QuerySet, and substituting in the supplied action (or constants in the last three cases).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant