uncloud-mravi/uncloud_django_based/uncloud/opennebula/views.py

17 lines
465 B
Python
Raw Normal View History

from rest_framework import viewsets, permissions
from .models import VM
from .serializers import OpenNebulaVMSerializer
2020-02-23 14:33:26 +00:00
class VMViewSet(viewsets.ModelViewSet):
2020-02-23 14:33:26 +00:00
permission_classes = [permissions.IsAuthenticated]
serializer_class = OpenNebulaVMSerializer
def get_queryset(self):
if self.request.user.is_superuser:
obj = VM.objects.all()
else:
obj = VM.objects.filter(owner=self.request.user)
return obj