Skip to content

Commit

Permalink
feat: simple api/v3/person/{id} endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards committed Oct 30, 2024
1 parent 5306f4c commit e05c224
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ietf/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
15 changes: 15 additions & 0 deletions ietf/person/api.py
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions ietf/person/serializers.py
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit e05c224

Please sign in to comment.