dynamicweb/opennebula_api/permissions.py
2017-05-11 12:45:09 +02:00

10 lines
310 B
Python

from rest_framework.permissions import BasePermission
from .models import VirtualMachine
class IsOwner(BasePermission):
def has_object_permission(self, request, view, obj):
if isinstance(obj, VirtualMachine):
return obj.owner == request.user
return obj.owner == request.user