Skip to content

Migrate permisison to Dry-Rest-Permissions #283

Open
@RignonNoel

Description

@RignonNoel

Some of the permissions are manage manually and not with Dry-Rest-Permission, we should migrate these special case to the common usage of Dry-Rest-Permission.

class CellViewSet(viewsets.ModelViewSet):
serializer_class = CellSerializer
queryset = Cell.objects.all()
filter_fields = '__all__'
permission_classes = (DRYPermissions,)
def get_permissions(self):
if self.action in ['list', 'retrieve']:
permission_classes = []
else:
permission_classes = [IsAdminUser]
return [permission() for permission in permission_classes]
class TaskTypeViewSet(viewsets.ModelViewSet):
serializer_class = TaskTypeSerializer
queryset = TaskType.objects.all()
filter_fields = '__all__'
permission_classes = (DRYPermissions,)
def get_permissions(self):
if self.action in ['list']:
permission_classes = []
else:
permission_classes = [IsAdminUser]
return [permission() for permission in permission_classes]
class EventViewSet(viewsets.ModelViewSet):
serializer_class = EventSerializer
queryset = Event.objects.all()
filterset_fields = {
'start_time': ['exact', 'gte', 'lte'],
'end_time': ['exact', 'gte', 'lte'],
'cell': ['exact'],
}
permission_classes = (DRYPermissions, DjangoFilterBackend)
parser_classes = (JSONParser, FormParser, MultiPartParser)
def get_permissions(self):
if self.action in ['list']:
permission_classes = []
else:
permission_classes = [IsAdminUser]
return [permission() for permission in permission_classes]

Ressources:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions