views.py
2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from rest_framework import permissions
from khudrive.api.serializers import UserSerializer,GroupSerializer
from rest_framework.decorators import action
from rest_framework.response import Response
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by('-date_joined')
serializer_class = UserSerializer
# permission_classes = [permissions.IsAuthenticated]
@action(detail=False, methods=['GET'])
def isIdPossible(self, request):
# user = self.get_object()
# serializer = PasswordSerializer(data=request.data)
# if serializer.is_valid():
return Response({
'message': 'possible'
})
# else:
# return Response(serializer.errors,
# status=status.HTTP_400_BAD_REQUEST)
#Sign Up
@action(detail=False, methods=['POST'])
def signUp(self, request):
if True:
return Response({
'message': 'user created'
})
else:
return Response(serializer.errors,
status=status.HTTP_400_BAD_REQUEST)
# Login, token create
@action(detail=False, methods=['POST'])
def login(self, request):
if True:
return Response({
'message': 'login success'
})
else:
return Response(serializer.errors,
status=status.HTTP_400_BAD_REQUEST)
# User 생성
@action(detail=True, methods=['GET'])
def getById(self, request, pk=None):
if True:
return Response({
'message': 'possible'
})
else:
return Response(serializer.errors,
status=status.HTTP_400_BAD_REQUEST)
class ItemViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = [permissions.IsAuthenticated]