2022-12-25 01:21:30 -05:00
|
|
|
from rest_framework import routers, serializers, viewsets
|
|
|
|
|
2024-01-17 21:17:24 -05:00
|
|
|
from .models import Flag, Member
|
2022-12-25 01:21:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
class MemberSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Member
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
|
|
|
|
class MemberViewSet(viewsets.ModelViewSet):
|
2023-01-23 15:16:29 -05:00
|
|
|
queryset = Member.objects.prefetch_related("flags")
|
2022-12-25 01:21:30 -05:00
|
|
|
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)
|