16 lines
465 B
Python
16 lines
465 B
Python
from rest_framework import viewsets, permissions
|
|
|
|
from .models import VM
|
|
from .serializers import OpenNebulaVMSerializer
|
|
|
|
class VMViewSet(viewsets.ModelViewSet):
|
|
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
|