diff options
Diffstat (limited to 'hyperkitty/api.py')
-rw-r--r-- | hyperkitty/api.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hyperkitty/api.py b/hyperkitty/api.py index 8b00e60..9481340 100644 --- a/hyperkitty/api.py +++ b/hyperkitty/api.py @@ -22,6 +22,7 @@ from rest_framework.response import Response from rest_framework import serializers from rest_framework.exceptions import ParseError +from hyperkitty.models import Tag from hyperkitty.lib import get_store @@ -56,6 +57,11 @@ class ThreadSerializer(serializers.Serializer): email_ids = serializers.CharField() participants = serializers.CharField() +class TagSerializer(serializers.ModelSerializer): + class Meta: + model = Tag + fields = ("list_address", "threadid", "tag") + class ListResource(APIView): """ Resource used to retrieve lists from the archives using the @@ -122,3 +128,14 @@ class SearchResource(APIView): return Response(status=404) else: return Response(EmailSerializer(threads, many=True).data) + + +class TagResource(APIView): + """ + Resource used to retrieve tags from the database using the REST API. + """ + + def get(self, request): + tags = Tag.objects.all() + serializer = TagSerializer(tags, many=True) + return Response(serializer.data) |