Skip to content

Commit

Permalink
WIP: start working on #25
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Apr 18, 2023
1 parent 15539b8 commit e64e4fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions apis_bibsonomy/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions apis_bibsonomy/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .models import Reference
from rest_framework import serializers


class ReferenceSerializer(serializers.ModelSerializer):
class Meta:
model = Reference
3 changes: 2 additions & 1 deletion apis_bibsonomy/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:ct>/<int:pk>' api_views.ListReferences.as_view(), name='listreferences')
]

0 comments on commit e64e4fd

Please sign in to comment.