2016-08-09 09:27:37 +00:00
|
|
|
# ~*~ coding: utf-8 ~*~
|
2016-08-23 16:11:13 +00:00
|
|
|
#
|
2016-08-09 09:27:37 +00:00
|
|
|
|
2016-08-26 08:56:50 +00:00
|
|
|
import logging
|
|
|
|
|
2016-09-06 08:40:44 +00:00
|
|
|
from rest_framework import generics
|
2016-08-23 16:11:13 +00:00
|
|
|
|
2016-09-06 13:44:23 +00:00
|
|
|
from .serializers import UserSerializer, UserGroupSerializer, UserAttributeSerializer, UserGroupEditSerializer
|
2016-08-24 09:14:21 +00:00
|
|
|
from .models import User, UserGroup
|
2016-08-23 16:11:13 +00:00
|
|
|
|
|
|
|
|
2016-08-26 08:56:50 +00:00
|
|
|
logger = logging.getLogger('jumpserver.users.api')
|
|
|
|
|
|
|
|
|
2016-08-24 11:42:16 +00:00
|
|
|
class UserListAddApi(generics.ListCreateAPIView):
|
2016-08-24 09:14:21 +00:00
|
|
|
queryset = User.objects.all()
|
|
|
|
serializer_class = UserSerializer
|
|
|
|
|
|
|
|
|
2016-08-24 11:42:16 +00:00
|
|
|
class UserDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView):
|
2016-08-23 16:11:13 +00:00
|
|
|
queryset = User.objects.all()
|
|
|
|
serializer_class = UserSerializer
|
2016-08-24 11:42:16 +00:00
|
|
|
|
2016-08-30 09:20:39 +00:00
|
|
|
def delete(self, request, *args, **kwargs):
|
|
|
|
print(self.request.data)
|
|
|
|
return super(UserDetailDeleteUpdateApi, self).delete(request, *args, **kwargs)
|
|
|
|
|
2016-08-25 16:51:05 +00:00
|
|
|
# def get(self, request, *args, **kwargs):
|
|
|
|
# print("hello world")
|
|
|
|
# print(request.user)
|
|
|
|
# return super(UserDetailDeleteUpdateApi, self).get(request, *args, **kwargs)
|
|
|
|
|
2016-08-24 11:42:16 +00:00
|
|
|
|
|
|
|
class UserGroupListAddApi(generics.ListCreateAPIView):
|
|
|
|
queryset = UserGroup.objects.all()
|
|
|
|
serializer_class = UserGroupSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class UserGroupDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView):
|
|
|
|
queryset = UserGroup.objects.all()
|
|
|
|
serializer_class = UserGroupSerializer
|
|
|
|
|
2016-09-06 08:40:44 +00:00
|
|
|
|
|
|
|
class UserAttributeApi(generics.RetrieveUpdateDestroyAPIView):
|
|
|
|
queryset = User.objects.all()
|
|
|
|
serializer_class = UserAttributeSerializer
|
2016-09-06 13:44:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserGroupEditApi(generics.RetrieveUpdateAPIView):
|
|
|
|
queryset = User.objects.all()
|
|
|
|
serializer_class = UserGroupEditSerializer
|