Remove unneeded users API view

The help-users API view is sufficient
This commit is contained in:
Jan Dittberner 2023-04-16 13:50:01 +02:00
parent a65b1574db
commit 0f91587c60
3 changed files with 4 additions and 27 deletions

View file

@ -13,7 +13,6 @@ from help import views as help_views
admin.autodiscover()
router = routers.DefaultRouter()
router.register(r"users", help_views.UserViewSet)
router.register(r"help-users", help_views.HelpUserViewSet)
urlpatterns = [

View file

@ -2,22 +2,14 @@
Serializers for the REST API
"""
from django.contrib.auth import get_user_model
from rest_framework import serializers
from help.models import HelpUser
User = get_user_model()
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ["url", "username", "helpuser"]
read_only_fields = ["username", "helpuser"]
class HelpUserSerializer(serializers.HyperlinkedModelSerializer):
user = serializers.StringRelatedField()
class Meta:
model = HelpUser
fields = [

View file

@ -1,21 +1,7 @@
from django.contrib.auth import get_user_model
from rest_framework import permissions, viewsets
from help.models import HelpUser
from help.serializers import HelpUserSerializer, UserSerializer
User = get_user_model()
class UserViewSet(viewsets.ReadOnlyModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by("-username")
serializer_class = UserSerializer
permission_classes = [permissions.IsAdminUser]
from help.serializers import HelpUserSerializer
class HelpUserViewSet(viewsets.ModelViewSet):
@ -24,6 +10,6 @@ class HelpUserViewSet(viewsets.ModelViewSet):
"""
queryset = HelpUser.objects.all().order_by("-user__username")
queryset = HelpUser.objects.all().order_by("user__username")
serializer_class = HelpUserSerializer
permission_classes = [permissions.IsAdminUser]