Remove unneeded users API view
The help-users API view is sufficient
This commit is contained in:
parent
a65b1574db
commit
0f91587c60
3 changed files with 4 additions and 27 deletions
|
@ -13,7 +13,6 @@ from help import views as help_views
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r"users", help_views.UserViewSet)
|
|
||||||
router.register(r"help-users", help_views.HelpUserViewSet)
|
router.register(r"help-users", help_views.HelpUserViewSet)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
|
@ -2,22 +2,14 @@
|
||||||
Serializers for the REST API
|
Serializers for the REST API
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from help.models import HelpUser
|
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):
|
class HelpUserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
user = serializers.StringRelatedField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = HelpUser
|
model = HelpUser
|
||||||
fields = [
|
fields = [
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
from django.contrib.auth import get_user_model
|
|
||||||
from rest_framework import permissions, viewsets
|
from rest_framework import permissions, viewsets
|
||||||
|
|
||||||
from help.models import HelpUser
|
from help.models import HelpUser
|
||||||
from help.serializers import HelpUserSerializer, UserSerializer
|
from help.serializers import HelpUserSerializer
|
||||||
|
|
||||||
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]
|
|
||||||
|
|
||||||
|
|
||||||
class HelpUserViewSet(viewsets.ModelViewSet):
|
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
|
serializer_class = HelpUserSerializer
|
||||||
permission_classes = [permissions.IsAdminUser]
|
permission_classes = [permissions.IsAdminUser]
|
||||||
|
|
Loading…
Reference in a new issue