2020-04-07 17:45:16 +00:00
|
|
|
|
2020-03-02 06:17:04 +00:00
|
|
|
from django.shortcuts import render
|
2020-04-07 17:45:16 +00:00
|
|
|
|
2020-04-03 17:27:49 +00:00
|
|
|
from rest_framework import viewsets, permissions
|
2020-03-02 06:17:04 +00:00
|
|
|
|
2020-04-03 17:27:49 +00:00
|
|
|
|
|
|
|
from .models import *
|
|
|
|
from .serializers import *
|
|
|
|
|
|
|
|
|
2020-04-06 20:30:01 +00:00
|
|
|
class VPNPoolViewSet(viewsets.ModelViewSet):
|
|
|
|
serializer_class = VPNPoolSerializer
|
|
|
|
permission_classes = [permissions.IsAdminUser]
|
|
|
|
queryset = VPNPool.objects.all()
|
|
|
|
|
|
|
|
|
|
|
|
class VPNNetworkViewSet(viewsets.ModelViewSet):
|
|
|
|
serializer_class = VPNNetworkSerializer
|
2020-04-03 17:27:49 +00:00
|
|
|
permission_classes = [permissions.IsAdminUser]
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
if self.request.user.is_superuser:
|
2020-04-06 20:30:01 +00:00
|
|
|
obj = VPNNetwork.objects.all()
|
2020-04-03 17:27:49 +00:00
|
|
|
else:
|
2020-04-06 20:30:01 +00:00
|
|
|
obj = VPNNetwork.objects.filter(owner=self.request.user)
|
2020-04-03 17:27:49 +00:00
|
|
|
|
|
|
|
return obj
|