From e7f4bd9cc60aa3ad230b31c3918df1f2043d6942 Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Sun, 12 Dec 2021 23:22:13 +0100 Subject: add grups views and modify info auth view --- auth_api/views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'auth_api') 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 from django.contrib.auth.models import User from django.http.response import Http404 from django.shortcuts import get_object_or_404 +from django.db.models import Q from rest_framework import permissions from rest_framework.authtoken.serializers import AuthTokenSerializer @@ -47,6 +48,15 @@ class UserInfo(APIView): def get(self, request): user = request.GET.get("pk", request.user) username = request.GET.get("username", None) + all_users = request.GET.get("all", None) + + if all_users: + users = User.objects.filter(~Q(username=request.user.username)) + serializer = UserSerializer(users, many=True) + + return Response(data={ + "users": serializer.data + }) if username: users = User.objects.filter(username__startswith = username)[:5] @@ -66,4 +76,4 @@ class UserInfo(APIView): return Response({ "user": serializer.data - }) \ No newline at end of file + }) -- cgit v1.2.3