|
|
@ -1,24 +1,26 @@
|
|
|
|
# ~*~ coding: utf-8 ~*~
|
|
|
|
# ~*~ coding: utf-8 ~*~
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
from rest_framework import viewsets
|
|
|
|
from rest_framework import viewsets
|
|
|
|
from rest_framework import status
|
|
|
|
from rest_framework import status
|
|
|
|
from rest_framework.response import Response
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
|
|
|
|
|
|
|
from serializers import *
|
|
|
|
from serializers import *
|
|
|
|
|
|
|
|
from permissions import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HostAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class HostAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = HostAlia.objects.all()
|
|
|
|
queryset = HostAlia.objects.all()
|
|
|
|
serializer_class = HostAliaSerializer
|
|
|
|
serializer_class = HostAliaSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
h_alias = self.get_queryset()
|
|
|
|
h_alias = self.get_queryset()
|
|
|
|
h_serializer = self.get_serializer(h_alias, many=True)
|
|
|
|
h_serializer = self.get_serializer(h_alias, many=True)
|
|
|
|
return Response(h_serializer.data)
|
|
|
|
return Response(h_serializer.data)
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
self.perform_create()
|
|
|
|
self.perform_create()
|
|
|
@ -48,14 +50,14 @@ class HostAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class CmdAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class CmdAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = CmdAlia.objects.all()
|
|
|
|
queryset = CmdAlia.objects.all()
|
|
|
|
serializer_class = CmdAliaSerializer
|
|
|
|
serializer_class = CmdAliaSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
c_alias = self.get_queryset()
|
|
|
|
c_alias = self.get_queryset()
|
|
|
|
c_serializer = self.get_serializer(c_alias, many=True)
|
|
|
|
c_serializer = self.get_serializer(c_alias, many=True)
|
|
|
|
return Response(c_serializer.data)
|
|
|
|
return Response(c_serializer.data)
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
self.perform_create()
|
|
|
|
self.perform_create()
|
|
|
@ -85,14 +87,14 @@ class CmdAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class UserAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class UserAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = UserAlia.objects.all()
|
|
|
|
queryset = UserAlia.objects.all()
|
|
|
|
serializer_class = UserAliaSerializer
|
|
|
|
serializer_class = UserAliaSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
u_alias = self.get_queryset()
|
|
|
|
u_alias = self.get_queryset()
|
|
|
|
u_serializer = self.get_serializer(u_alias, many=True)
|
|
|
|
u_serializer = self.get_serializer(u_alias, many=True)
|
|
|
|
return Response(u_serializer.data)
|
|
|
|
return Response(u_serializer.data)
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
self.perform_create()
|
|
|
|
self.perform_create()
|
|
|
@ -122,14 +124,14 @@ class UserAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class RunasAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class RunasAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = RunasAlia.objects.all()
|
|
|
|
queryset = RunasAlia.objects.all()
|
|
|
|
serializer_class = RunasAliaSerializer
|
|
|
|
serializer_class = RunasAliaSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
r_alias = self.get_queryset()
|
|
|
|
r_alias = self.get_queryset()
|
|
|
|
r_serializer = self.get_serializer(r_alias, many=True)
|
|
|
|
r_serializer = self.get_serializer(r_alias, many=True)
|
|
|
|
return Response(r_serializer.data)
|
|
|
|
return Response(r_serializer.data)
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
self.perform_create()
|
|
|
|
self.perform_create()
|
|
|
@ -159,14 +161,14 @@ class RunasAliaViewSet(viewsets.GenericViewSet):
|
|
|
|
class ExtraconfViewSet(viewsets.GenericViewSet):
|
|
|
|
class ExtraconfViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = Extra_conf.objects.all()
|
|
|
|
queryset = Extra_conf.objects.all()
|
|
|
|
serializer_class = ExtraconfSerializer
|
|
|
|
serializer_class = ExtraconfSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
e_alias = self.get_queryset()
|
|
|
|
e_alias = self.get_queryset()
|
|
|
|
e_serializer = self.get_serializer(e_alias, many=True)
|
|
|
|
e_serializer = self.get_serializer(e_alias, many=True)
|
|
|
|
return Response(e_serializer.data)
|
|
|
|
return Response(e_serializer.data)
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer = self.get_serializer(data=self.request.data)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
serializer.is_valid(raise_exception=True)
|
|
|
|
self.perform_create()
|
|
|
|
self.perform_create()
|
|
|
@ -196,19 +198,19 @@ class ExtraconfViewSet(viewsets.GenericViewSet):
|
|
|
|
class PrivilegeViewSet(viewsets.GenericViewSet):
|
|
|
|
class PrivilegeViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = Privilege.objects.all()
|
|
|
|
queryset = Privilege.objects.all()
|
|
|
|
serializer_class = PrivilegeSerializer
|
|
|
|
serializer_class = PrivilegeSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def retrieve(self, *args, **kwargs):
|
|
|
|
def retrieve(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, *args, **kwargs):
|
|
|
|
def update(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def destroy(self, *args, **kwargs):
|
|
|
|
def destroy(self, *args, **kwargs):
|
|
|
|
privilege = self.get_object()
|
|
|
|
privilege = self.get_object()
|
|
|
@ -222,19 +224,19 @@ class PrivilegeViewSet(viewsets.GenericViewSet):
|
|
|
|
class SudoViewSet(viewsets.GenericViewSet):
|
|
|
|
class SudoViewSet(viewsets.GenericViewSet):
|
|
|
|
queryset = Sudo.objects.all()
|
|
|
|
queryset = Sudo.objects.all()
|
|
|
|
serializer_class = SudoSerializer
|
|
|
|
serializer_class = SudoSerializer
|
|
|
|
permission_classes = None
|
|
|
|
permission_classes = (AdminUserRequired,)
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
def create(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def retrieve(self, *args, **kwargs):
|
|
|
|
def retrieve(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, *args, **kwargs):
|
|
|
|
def update(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
raise exc.ServiceNotImplemented
|
|
|
|
|
|
|
|
|
|
|
|
def destroy(self, *args, **kwargs):
|
|
|
|
def destroy(self, *args, **kwargs):
|
|
|
|
sudo = self.get_object()
|
|
|
|
sudo = self.get_object()
|
|
|
|