Skip to content
Snippets Groups Projects
Commit fe145aaa authored by Jan Bernoth's avatar Jan Bernoth
Browse files

Updated API (recent articles)

parent 50aa3778
No related branches found
No related tags found
1 merge request!121Updated API (recent articles)
Pipeline #46469 passed
""" Views with OpenAPI annotations """
import datetime
import logging
from django.db.models import Q
from django.shortcuts import render
from django.utils import timezone
from django.utils.decorators import method_decorator
......@@ -83,13 +85,18 @@ class MediumTypeDetail(generics.RetrieveUpdateDestroyAPIView): # pylint: disabl
class TimelineList(generics.ListAPIView):
""" List all timeline objects """
queryset = Timeline.objects.all()
today = datetime.datetime.today()
datetime_recent = today - datetime.timedelta(days=365)
queryset = Timeline.objects.filter(
Q(year=today.year, month__lte=today.month) | Q(year=datetime_recent.year, month__gte=datetime_recent.month))
serializer_class = TimelineSerializer
class OverviewList(generics.ListAPIView):
""" List all overview objects """
queryset = Overview.objects.all()
today = datetime.datetime.today()
datetime_recent = today - datetime.timedelta(days=90)
queryset = Overview.objects.filter(date_of_publication__range=[datetime_recent, today])
serializer_class = OverviewSerializer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment