diff options
Diffstat (limited to 'hyperkitty')
-rw-r--r-- | hyperkitty/api.py | 17 | ||||
-rw-r--r-- | hyperkitty/templates/api.html | 17 | ||||
-rw-r--r-- | hyperkitty/urls.py | 4 |
3 files changed, 34 insertions, 4 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) diff --git a/hyperkitty/templates/api.html b/hyperkitty/templates/api.html index 750c69b..7537381 100644 --- a/hyperkitty/templates/api.html +++ b/hyperkitty/templates/api.html @@ -38,7 +38,7 @@ retrieve the information known about all the mailing-lists. </a> </p> </div> - <div class="even" style="padding-left: 1em"> + <div class="odd" style="padding-left: 1em"> <h3>Emails <a>/api/email/<list name>/<Message-ID></a></h3> <p> Using the address /api/email/<list name>/<Message-ID> you will be able to @@ -49,7 +49,7 @@ retrieve the information known about a specific email on the specified mailing-l </a> </p> </div> - <div class="odd" style="padding-left: 1em"> + <div class="even" style="padding-left: 1em"> <h3>Threads <a>/api/thread/<list name>/<ThreadID></a></h3> <p> Using the address /api/thread/<list name>/<Message-ID> you will be able to @@ -60,7 +60,7 @@ retrieve the all the email for a specific thread on the specified mailing-list. </a> </p> </div> - <div class="even" style="padding-left: 1em"> + <div class="odd" style="padding-left: 1em"> <h3>Search <a>/api/search/<list name>/<field>/<keyword></a></h3> <p> Using the address /api/search/<list name>/<field>/<keyword> you will be able to @@ -78,4 +78,15 @@ search for all emails of the specified mailing-list containing the provided keyw </a> </p> </div> + <div class="even" style="padding-left: 1em"> + <h3>Tags <a>/api/tag/</a></h3> + <p> +Using the address /api/tag/ you will be able to +retrieve the list of tags. + </p> + <p> For example: <a href="{% url 'api_tag' %}?format=api"> + {% url 'api_tag' %} + </a> + </p> + </div> {% endblock %} diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py index 9277922..015737b 100644 --- a/hyperkitty/urls.py +++ b/hyperkitty/urls.py @@ -22,7 +22,8 @@ from django.conf.urls import patterns, include, url from django.views.generic.base import TemplateView -from api import ListResource, EmailResource, ThreadResource, SearchResource +from hyperkitty.api import ListResource, EmailResource, ThreadResource, SearchResource +from hyperkitty.api import TagResource from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib.auth.views import logout as logout_view @@ -101,6 +102,7 @@ urlpatterns = patterns('hyperkitty.views', ThreadResource.as_view(), name="api_thread"), url(r'^api/search\/(?P<mlist_fqdn>[^/@]+@[^/@]+)\/(?P<field>.*)\/(?P<keyword>.*)/', SearchResource.as_view(), name="api_search"), + url(r'^api/tag\/', TagResource.as_view(), name="api_tag"), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), |