Skip to content

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 sergioisidoro force-pushed the sergioisidoro-isolate-get-perm branch from e7b6269 to 6cd67cc Compare December 22, 2021 18:06
@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.

1 participant