++views/permissions

This commit is contained in:
Nico Schottelius 2020-02-20 19:38:43 +01:00
parent f8182e00e8
commit 118c66799c
2 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,6 @@
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class CreditCard(models.Model):
pass

View file

@ -3,17 +3,30 @@ from django.shortcuts import render
# Create your views here. # Create your views here.
from django.contrib.auth.models import User, Group from django.contrib.auth.models import User, Group
from rest_framework import viewsets from rest_framework import viewsets, permissions
from api.serializers import UserSerializer, GroupSerializer from api.serializers import UserSerializer, GroupSerializer
class CreditCardViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows credit cards to be listed
"""
queryset = User.objects.all().order_by('-date_joined')
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
class UserViewSet(viewsets.ModelViewSet): class UserViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows users to be viewed or edited. API endpoint that allows users to be viewed or edited.
""" """
queryset = User.objects.all().order_by('-date_joined') queryset = User.objects.all().order_by('-date_joined')
serializer_class = UserSerializer serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
class GroupViewSet(viewsets.ModelViewSet): class GroupViewSet(viewsets.ModelViewSet):
""" """
@ -21,3 +34,5 @@ class GroupViewSet(viewsets.ModelViewSet):
""" """
queryset = Group.objects.all() queryset = Group.objects.all()
serializer_class = GroupSerializer serializer_class = GroupSerializer
permission_classes = [permissions.IsAuthenticated]