1
This commit is contained in:
commit
8c95bbf909
126 files changed
+16922
No files matched your search
@@ -0,0 +1,51 @@
|
||||
from rest_framework import status
|
||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from .renderers import UserJSONRenderer
|
||||
from userauth.models import *
|
||||
from .models import *
|
||||
# from .serializers import RegistrationSerializer
|
||||
|
||||
# class RegistrationAPIView(APIView):
|
||||
# """
|
||||
# Разрешить всем пользователям (аутентифицированным и нет) доступ к данному эндпоинту.
|
||||
# """
|
||||
# permission_classes = (AllowAny,)
|
||||
# serializer_class = RegistrationSerializer
|
||||
# renderer_classes = (UserJSONRenderer,)
|
||||
|
||||
# def post(self, request):
|
||||
# user = request.data.get("user",{})
|
||||
# # Паттерн создания сериализатора, валидации и сохранения - довольно
|
||||
# # стандартный, и его можно часто увидеть в реальных проектах.
|
||||
|
||||
# serializer = self.serializer_class(data=user)
|
||||
# serializer.is_valid(raise_exception=True)
|
||||
# serializer.save()
|
||||
|
||||
# return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
|
||||
class UserAPIView(APIView):
|
||||
permission_classes = (IsAuthenticated,)
|
||||
# serializer_class = RegistrationSerializer
|
||||
def get(self, request):
|
||||
# serializer = self.serializer_class(data=request.user)
|
||||
# serializer.is_valid(raise_exception=True)
|
||||
return Response('user')
|
||||
|
||||
class getuserAPIView(APIView):
|
||||
permission_classes = (AllowAny,)
|
||||
|
||||
|
||||
|
||||
def get(self, request):
|
||||
userlogin = request.query_params.get('userlogin')
|
||||
print('--------------------------', self.request.query_params)
|
||||
|
||||
queryset = model_to_dict(DictEmployee.objects.using('user_directory').get(login=userlogin))
|
||||
|
||||
# queryset['responsible'] = [model_to_dict(x) for x in OrderResponsibilityEmployee.objects.using('user_directory').raw("SELECT * FROM order_responsibility_employee")]
|
||||
|
||||
return Response(queryset)
|
||||
|
||||
Reference in new issue
Block a user