diff --git a/ietf/api/urls.py b/ietf/api/urls.py index 707bed2920..1c0a9a6195 100644 --- a/ietf/api/urls.py +++ b/ietf/api/urls.py @@ -10,10 +10,12 @@ from ietf.api import views as api_views from ietf.doc import views_ballot from ietf.meeting import views as meeting_views +from ietf.person import api as person_api from ietf.submit import views as submit_views from ietf.utils.urls import url router = routers.DefaultRouter() # v3 api router +router.register("person", person_api.PersonViewSet) api.autodiscover() diff --git a/ietf/person/api.py b/ietf/person/api.py new file mode 100644 index 0000000000..2d5be85f12 --- /dev/null +++ b/ietf/person/api.py @@ -0,0 +1,15 @@ +# Copyright The IETF Trust 2024, All Rights Reserved +"""DRF API Views""" + +from rest_framework import mixins, viewsets + +from .models import Person + + +class PersonViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet): + """Person viewset + + Mostly demo for now. Only allows retrieving single instances. Think hard about permissions before + allowing write or list access. + """ + queryset = Person.objects.all() diff --git a/ietf/person/serializers.py b/ietf/person/serializers.py new file mode 100644 index 0000000000..adee96a7dd --- /dev/null +++ b/ietf/person/serializers.py @@ -0,0 +1,14 @@ +# Copyright The IETF Trust 2024, All Rights Reserved +"""DRF Serializers""" + +from rest_framework import serializers + +from .models import Person + + +class PersonSerializer(serializers.ModelSerializer): + """Person serializer""" + + class Meta: + model = Person + fields = ["id", "name"]