summaryrefslogtreecommitdiffstats
path: root/hyperkitty/api.py
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2013-06-19 18:28:22 +0200
committerAurélien Bompard <aurelien@bompard.org>2013-06-19 18:28:22 +0200
commita0a04dd66690bd43e03b07f80b82f7201615ae81 (patch)
treefc7aa23d7a23097b0a41b70dd4be704efc256f64 /hyperkitty/api.py
parent6ada7fb3f6842998e274d06900d353142992c622 (diff)
downloadhyperkitty-a0a04dd66690bd43e03b07f80b82f7201615ae81.tar.gz
hyperkitty-a0a04dd66690bd43e03b07f80b82f7201615ae81.tar.xz
hyperkitty-a0a04dd66690bd43e03b07f80b82f7201615ae81.zip
Add the tags to the REST API
Diffstat (limited to 'hyperkitty/api.py')
-rw-r--r--hyperkitty/api.py17
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)