uncloud-mravi/uncloud_django_based/uncloud/uncloud_net/views.py
Nico Schottelius 938f0a3390 update to work on different computer
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
2020-04-07 19:45:16 +02:00

27 lines
682 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