Skip to content
Snippets Groups Projects
Verified Commit 06b310ba authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: remove usage of privileged group

parent 318fd135
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,6 @@ from rest_framework.exceptions import ValidationError ...@@ -32,7 +32,6 @@ from rest_framework.exceptions import ValidationError
from rest_framework.pagination import LimitOffsetPagination from rest_framework.pagination import LimitOffsetPagination
from rest_framework.response import Response from rest_framework.response import Response
from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import IntegrityError from django.db import IntegrityError
from django.http import Http404, HttpResponse, JsonResponse from django.http import Http404, HttpResponse, JsonResponse
...@@ -266,12 +265,12 @@ class APIUserViewSet( ...@@ -266,12 +265,12 @@ class APIUserViewSet(
search_fields = ["username", "first_name", "last_name", "email"] search_fields = ["username", "first_name", "last_name", "email"]
def get_queryset(self): def get_queryset(self):
"""The queryset contains all the users if the requesting user is a superuser or member of """The queryset contains all the users if the requesting user is a superuser, otherwise it
the privileged group, otherwise it only contains the requesting user.""" only contains the requesting user."""
user = self.request.user user = self.request.user
if user.is_superuser or user.groups.filter(name=settings.PRIVILEGED_GROUP).exists(): if user.is_superuser:
return User.objects.all() return User.objects.all()
else: else:
return User.objects.filter(pk=user.id) return User.objects.filter(pk=user.id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment