diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-12 23:22:13 +0100 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-12 23:22:13 +0100 |
commit | e7f4bd9cc60aa3ad230b31c3918df1f2043d6942 (patch) | |
tree | 17a99bdffed70ccd156cff935c0851276dc5a01f /auth_api | |
parent | ff53fd490b02536733f6618908760b9e3d52eeb3 (diff) | |
download | lom_api-e7f4bd9cc60aa3ad230b31c3918df1f2043d6942.tar.gz lom_api-e7f4bd9cc60aa3ad230b31c3918df1f2043d6942.zip |
add grups views and modify info auth view
Diffstat (limited to 'auth_api')
-rw-r--r-- | auth_api/views.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/auth_api/views.py b/auth_api/views.py index cd32914..36fc7e0 100644 --- a/auth_api/views.py +++ b/auth_api/views.py | |||
@@ -2,6 +2,7 @@ from django.contrib.auth import login | |||
2 | from django.contrib.auth.models import User | 2 | from django.contrib.auth.models import User |
3 | from django.http.response import Http404 | 3 | from django.http.response import Http404 |
4 | from django.shortcuts import get_object_or_404 | 4 | from django.shortcuts import get_object_or_404 |
5 | from django.db.models import Q | ||
5 | 6 | ||
6 | from rest_framework import permissions | 7 | from rest_framework import permissions |
7 | from rest_framework.authtoken.serializers import AuthTokenSerializer | 8 | from rest_framework.authtoken.serializers import AuthTokenSerializer |
@@ -47,6 +48,15 @@ class UserInfo(APIView): | |||
47 | def get(self, request): | 48 | def get(self, request): |
48 | user = request.GET.get("pk", request.user) | 49 | user = request.GET.get("pk", request.user) |
49 | username = request.GET.get("username", None) | 50 | username = request.GET.get("username", None) |
51 | all_users = request.GET.get("all", None) | ||
52 | |||
53 | if all_users: | ||
54 | users = User.objects.filter(~Q(username=request.user.username)) | ||
55 | serializer = UserSerializer(users, many=True) | ||
56 | |||
57 | return Response(data={ | ||
58 | "users": serializer.data | ||
59 | }) | ||
50 | 60 | ||
51 | if username: | 61 | if username: |
52 | users = User.objects.filter(username__startswith = username)[:5] | 62 | users = User.objects.filter(username__startswith = username)[:5] |
@@ -66,4 +76,4 @@ class UserInfo(APIView): | |||
66 | 76 | ||
67 | return Response({ | 77 | return Response({ |
68 | "user": serializer.data | 78 | "user": serializer.data |
69 | }) \ No newline at end of file | 79 | }) |