uncloud-mravi/nicohack202002/uncloud/uncloud_api/views.py

38 lines
1 KiB
Python
Raw Normal View History

from django.shortcuts import render
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
2020-02-20 18:38:43 +00:00
from rest_framework import viewsets, permissions
from .serializers import UserSerializer, GroupSerializer
2020-02-20 17:58:07 +00:00
2020-02-20 18:38:43 +00:00
class CreditCardViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows credit cards to be listed
"""
queryset = get_user_model().objects.all().order_by('-date_joined')
2020-02-20 18:38:43 +00:00
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
2020-02-20 17:58:07 +00:00
class UserViewSet(viewsets.ModelViewSet):
2020-02-20 18:38:43 +00:00
2020-02-20 17:58:07 +00:00
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = get_user_model().objects.all().order_by('-date_joined')
2020-02-20 17:58:07 +00:00
serializer_class = UserSerializer
2020-02-20 18:38:43 +00:00
permission_classes = [permissions.IsAuthenticated]
2020-02-20 17:58:07 +00:00
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
2020-02-20 18:38:43 +00:00
permission_classes = [permissions.IsAuthenticated]