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 support of DRF OR, AND, NOT operands #202

Merged

Conversation

MishaGubsky
Copy link
Contributor

@MishaGubsky MishaGubsky commented May 11, 2024

Add support of DRF permission operands.

The problem:

from djangochannelsrestframework.consumers import AsyncAPIConsumer
from rest_framework.permissions import BasePermission as DRFBasePermission

class PermissionA(DRFBasePermission):
     ...

class PermissionB(DRFBasePermission):
     ...

class PermissionC(DRFBasePermission):
     ...

class PermissionD(DRFBasePermission):
     ...

class PermissionE(DRFBasePermission):
     ...

class MyConsumer(AsyncAPIConsumer):
    permission_classes = (PermissionA | PermissionB, PermissionC & PermissionD, ~PermissionE)
    ...

Copy link
Member

@hishnash hishnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice this is a supper clean solution :)

@hishnash hishnash merged commit 956f2ba into NilCoalescing:master May 13, 2024
14 checks passed
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

2 participants