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

Better handling of "multi-action" views #12

Closed
ian-ross opened this issue Feb 9, 2016 · 2 comments
Closed

Better handling of "multi-action" views #12

ian-ross opened this issue Feb 9, 2016 · 2 comments
Assignees

Comments

@ian-ross
Copy link
Contributor

ian-ross commented Feb 9, 2016

If you have something like a DRF ListCreateAPIView, how do you permission it? The GET handler is for listing objects, the POST handler for creating them. Perhaps the permission_required attribute in PermissionRequiredMixin should take a dictionary mapping HTTP methods to permissions?

@oliverroick
Copy link
Member

For organisations API views, I had to implement a Django Rest Framework specific PermissionRequiredMixin, because permission verification is different in DRF. The mixin also handles permissions for multi-action views (mixin code).

Usage:

class OrganisationList(APIVIew):
    permission_required = {
        'GET': 'org.list',
        'POST': 'org.create'
    }

@ian-ross
Copy link
Contributor Author

Here, I'm going to pull the permissions features that @oliverroick has implemented in Cadasta/cadasta-platform#64 into django-tutelary, adding some additional options to the actions attribute for permissioned models and the permission_required attribute in the PermissionsRequiredMixin. In particular, as well as Oliver's dictionary-based approach to permissions for "multi-method" views, I'll also add the option of providing a callable at various places in permission_required to allow for a more flexible approach to deciding what permissions are needed in a view.

@ian-ross ian-ross self-assigned this Mar 4, 2016
@ian-ross ian-ross closed this as completed Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants