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

20 lines
504 B
Python
Raw Normal View History

from django.shortcuts import render
from rest_framework import viewsets, permissions
from .models import *
from .serializers import *
class VPNProductViewSet(viewsets.ModelViewSet):
serializer_class = VPNProductSerializer
permission_classes = [permissions.IsAdminUser]
def get_queryset(self):
if self.request.user.is_superuser:
obj = VPNProduct.objects.all()
else:
obj = VPNProduct.objects.filter(owner=self.request.user)
return obj