NilCoalescing / djangochannelsrestframework

A Rest-framework for websockets using Django channels-v4
https://djangochannelsrestframework.readthedocs.io/en/latest/
MIT License
613 stars 86 forks source link

Add support of DRF OR, AND, NOT operands #202

Closed MishaGubsky closed 4 months ago

MishaGubsky commented 4 months ago

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)
    ...