31 lines
757 B
Python
31 lines
757 B
Python
from rest_framework import routers, serializers, viewsets
|
|
|
|
from .models import Member, Flag
|
|
|
|
|
|
class MemberSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = Member
|
|
fields = "__all__"
|
|
|
|
|
|
class MemberViewSet(viewsets.ModelViewSet):
|
|
queryset = Member.objects.prefetch_related("flags")
|
|
serializer_class = MemberSerializer
|
|
|
|
|
|
class FlagSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = Flag
|
|
fields = "__all__"
|
|
|
|
|
|
class FlagViewSet(viewsets.ModelViewSet):
|
|
queryset = Flag.objects.all()
|
|
serializer_class = FlagSerializer
|
|
|
|
|
|
router = routers.DefaultRouter()
|
|
router.register(r"membershipworks/member", MemberViewSet)
|
|
router.register(r"membershipworks/flag", FlagViewSet)
|