24 lines
941 B
Python
24 lines
941 B
Python
from django.shortcuts import render
|
|
from rest_framework.response import Response
|
|
from .models import Paper, PaperAbstract
|
|
from .serializers import PaperListSerializer
|
|
from apps.utils.viewsets import CustomGenericViewSet, CustomListModelMixin
|
|
from rest_framework.permissions import AllowAny
|
|
|
|
# Create your views here.
|
|
class PaperViewSet(CustomGenericViewSet, CustomListModelMixin):
|
|
queryset = Paper.objects.all()
|
|
serializer_class = PaperListSerializer
|
|
filterset_fields = ["publication_year", "type", "fetch_status"]
|
|
search_fields = ['title', 'first_author', 'first_author_institution']
|
|
ordering = ["-publication_date", "-create_time"]
|
|
|
|
def get_authenticators(self):
|
|
if self.request.method == 'GET':
|
|
return []
|
|
return super().get_authenticators()
|
|
|
|
def get_permissions(self):
|
|
if self.request.method == 'GET':
|
|
return [AllowAny()]
|
|
return super().get_permissions() |