mirror of https://github.com/jumpserver/jumpserver
22 lines
679 B
Python
22 lines
679 B
Python
|
from rest_framework.viewsets import ModelViewSet
|
||
|
|
||
|
from assets.models import Platform
|
||
|
from assets.serializers import PlatformSerializer
|
||
|
|
||
|
|
||
|
__all__ = ['AssetPlatformViewSet']
|
||
|
|
||
|
|
||
|
class AssetPlatformViewSet(ModelViewSet):
|
||
|
queryset = Platform.objects.all()
|
||
|
serializer_class = PlatformSerializer
|
||
|
filterset_fields = ['name', 'base']
|
||
|
search_fields = ['name']
|
||
|
|
||
|
def check_object_permissions(self, request, obj):
|
||
|
if request.method.lower() in ['delete', 'put', 'patch'] and obj.internal:
|
||
|
self.permission_denied(
|
||
|
request, message={"detail": "Internal platform"}
|
||
|
)
|
||
|
return super().check_object_permissions(request, obj)
|