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 59e0c8c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
18 changes: 18 additions & 0 deletions apis_bibsonomy/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,27 @@
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import viewsets, generics

from .models import Reference
from .utils import BibsonomyEntry
from .serializers import ReferenceSerializer

class ReferenceList(APIView):
"""
API endpoint that allows references to be viewed.
"""
authentication_classes = []
permission_classes = []

def post(self, request, format=None):
serializer = ReferenceSerializer(data=request.data, many=True)
references = []
if serializer.is_valid():
for ref in serializer.data:
print(ref)
references.append(Reference.objecs.get(content_typ_id=ref['content_typ_id'], object_id=ref['object_id']))
return Response(data=references)


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.Serializer):
content_type_id = serializers.IntegerField()
object_id = serializers.IntegerField()
5 changes: 3 additions & 2 deletions apis_bibsonomy/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from rest_framework.routers import DefaultRouter
from django.urls import path
from . import api_views
from . import autocompletes
Expand All @@ -6,6 +7,6 @@

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.ReferenceList.as_view(), name='referenceslist'),
]

0 comments on commit 59e0c8c

Please sign in to comment.