33 lines
955 B
Python
33 lines
955 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 VPNNetworkReservationViewSet(viewsets.ModelViewSet):
|
|
serializer_class = VPNNetworkReservationSerializer
|
|
permission_classes = [permissions.IsAdminUser]
|
|
queryset = VPNNetworkReservation.objects.all()
|
|
|
|
|
|
class VPNNetworkViewSet(viewsets.ModelViewSet):
|
|
serializer_class = VPNNetworkSerializer
|
|
# permission_classes = [permissions.IsAdminUser]
|
|
permission_classes = [permissions.IsAuthenticated]
|
|
|
|
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
|