dynamicweb/opennebula_api/permissions.py

11 lines
310 B
Python
Raw Normal View History

2017-05-11 10:45:09 +00:00
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