diff --git a/apis_bibsonomy/api_views.py b/apis_bibsonomy/api_views.py index 16bca63..d725170 100644 --- a/apis_bibsonomy/api_views.py +++ b/apis_bibsonomy/api_views.py @@ -8,9 +8,24 @@ from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView +from rest_framework import viewsets from .models import Reference from .utils import BibsonomyEntry +from .serializers import ReferenceSerializer + +class ListReferences(viewsets.ReadOnlyModelViewSet): + """ + API endpoint that allows references to be viewed. + """ + queryset = Reference.objects.all() + serializer_class = ReferenceSerializer + permission_classes = [IsAuthenticated] + + def get_queryset(self): + ct = self.kwargs['ct'] + pk = self.kwargs['pk'] + return Reference.objects.filter(content_type = ct, object_id = pk) class SaveBibsonomyEntry(APIView): diff --git a/apis_bibsonomy/serializers.py b/apis_bibsonomy/serializers.py new file mode 100644 index 0000000..d6d17fb --- /dev/null +++ b/apis_bibsonomy/serializers.py @@ -0,0 +1,7 @@ +from .models import Reference +from rest_framework import serializers + + +class ReferenceSerializer(serializers.ModelSerializer): + class Meta: + model = Reference diff --git a/apis_bibsonomy/urls.py b/apis_bibsonomy/urls.py index 38bc236..a5fb416 100644 --- a/apis_bibsonomy/urls.py +++ b/apis_bibsonomy/urls.py @@ -6,6 +6,7 @@ urlpatterns = [ path('save_get/', api_views.SaveBibsonomyEntry.as_view(), name='savegetbibsonomyentry'), - path('autocomplete/', autocompletes.BibsonomyAutocomplete.as_view(), name='bibsonomyautocomplete') + path('autocomplete/', autocompletes.BibsonomyAutocomplete.as_view(), name='bibsonomyautocomplete'), + path('references//', api_views.ListReferences.as_view(), name='listreferences') ]