forked from uncloud/uncloud
Rename / prepare for merge with uncloud repo
This commit is contained in:
parent
23203ff418
commit
7a6c8739f6
118 changed files with 1499 additions and 0 deletions
17
uncloud_django_based/uncloud/uncloud_auth/views.py
Normal file
17
uncloud_django_based/uncloud/uncloud_auth/views.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from rest_framework import viewsets, permissions, status
|
||||
from .serializers import *
|
||||
|
||||
class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
serializer_class = UserSerializer
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
def get_queryset(self):
|
||||
if self.request.user.is_superuser:
|
||||
obj = get_user_model().objects.all()
|
||||
else:
|
||||
# This is a bit stupid: we have a user, we create a queryset by
|
||||
# matching on the username. But I don't know a "nicer" way.
|
||||
# Nico, 2020-03-18
|
||||
obj = get_user_model().objects.filter(username=self.request.user.username)
|
||||
|
||||
return obj
|
||||
Loading…
Add table
Add a link
Reference in a new issue