forked from uncloud/uncloud
2cda4dd57b
Best practice See https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project
37 lines
1 KiB
Python
37 lines
1 KiB
Python
from django.shortcuts import render
|
|
from django.contrib.auth import get_user_model
|
|
from django.contrib.auth.models import Group
|
|
|
|
from rest_framework import viewsets, permissions
|
|
|
|
from .serializers import UserSerializer, GroupSerializer
|
|
|
|
class CreditCardViewSet(viewsets.ModelViewSet):
|
|
|
|
"""
|
|
API endpoint that allows credit cards to be listed
|
|
"""
|
|
queryset = get_user_model().objects.all().order_by('-date_joined')
|
|
serializer_class = UserSerializer
|
|
|
|
permission_classes = [permissions.IsAuthenticated]
|
|
|
|
|
|
class UserViewSet(viewsets.ModelViewSet):
|
|
|
|
"""
|
|
API endpoint that allows users to be viewed or edited.
|
|
"""
|
|
queryset = get_user_model().objects.all().order_by('-date_joined')
|
|
serializer_class = UserSerializer
|
|
|
|
permission_classes = [permissions.IsAuthenticated]
|
|
|
|
class GroupViewSet(viewsets.ModelViewSet):
|
|
"""
|
|
API endpoint that allows groups to be viewed or edited.
|
|
"""
|
|
queryset = Group.objects.all()
|
|
serializer_class = GroupSerializer
|
|
|
|
permission_classes = [permissions.IsAuthenticated]
|