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

Merge branch 'recent_articles' into 'master'

Updated API (recent articles)

See merge request !121
parents 50aa3778 fe145aaa
No related branches found
No related tags found
1 merge request!121Updated API (recent articles)
Pipeline #46813 passed with warnings
""" 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