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

Isolate viewset get permission from model #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sergioisidoro
Copy link
Contributor

Based on #155 , attempting to isolate the dependency of viewsets from the Model Mixins.

This allows users to avoid the RulesModelMixin by defining a custom viewset mixin:

from rules.contrib.rest_framework import AutoPermissionViewSetMixin

MyCustomAutoPermissionViewSetMixin:
  def get_permission_for_model(self, model, perm_type):
       return "%s.%s_%s" % (model._meta.app_label, perm_type, model._meta.model_name)

....

class PostViewSet(MyCustomAutoPermissionViewSetMixin, ModelViewSet):
    queryset = Post.objects.all()
    serializer_class = PostSerializer

@sergioisidoro
Copy link
Contributor Author

Tests failing because of Django 4.0 -> #158

@sergioisidoro
Copy link
Contributor Author

Rebased this and #157 to master, with the test fixes.

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

Successfully merging this pull request may close these issues.

None yet

1 participant