uncloud-mravi/uncloud_django_based/uncloud/uncloud_net/views.py
Nico Schottelius 913e992a48 [vpn] fix urls
2020-04-06 22:30:01 +02:00

25 lines
680 B
Python

from django.shortcuts import render
from rest_framework import viewsets, permissions
from .models import *
from .serializers import *
class VPNPoolViewSet(viewsets.ModelViewSet):
serializer_class = VPNPoolSerializer
permission_classes = [permissions.IsAdminUser]
queryset = VPNPool.objects.all()
class VPNNetworkViewSet(viewsets.ModelViewSet):
serializer_class = VPNNetworkSerializer
permission_classes = [permissions.IsAdminUser]
def get_queryset(self):
if self.request.user.is_superuser:
obj = VPNNetwork.objects.all()
else:
obj = VPNNetwork.objects.filter(owner=self.request.user)
return obj