summaryrefslogtreecommitdiff
path: root/app/posts/views
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-02-01 09:47:50 -0600
committerluxagraf <sng@luxagraf.net>2023-02-01 09:47:50 -0600
commitfa7d1b24229a4570dc32fb2ba848631093b82020 (patch)
treef0053110cda74673be8edc34c011dfbf4dda4fcd /app/posts/views
parent000d51010fe1989bd08279cabcab957cc2e57d0a (diff)
sightings: restricted jrnl results to a month on either side of the post
date
Diffstat (limited to 'app/posts/views')
-rw-r--r--app/posts/views/jrnl_views.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/posts/views/jrnl_views.py b/app/posts/views/jrnl_views.py
index bfc0a42..6692b0f 100644
--- a/app/posts/views/jrnl_views.py
+++ b/app/posts/views/jrnl_views.py
@@ -1,3 +1,4 @@
+import datetime
from django.views.generic import ListView
from django.views.generic.detail import DetailView
from django.views.generic.dates import DateDetailView
@@ -103,10 +104,14 @@ class JrnlDetailView(DateDetailView):
def get_context_data(self, **kwargs):
context = super(JrnlDetailView, self).get_context_data(**kwargs)
+ timeago = self.object.pub_date - datetime.timedelta(days=45)
+ timepadding = self.object.pub_date + datetime.timedelta(days=30)
context['wildlife'] = Sighting.objects.filter(
Q(location=self.location) |
Q(location__in=Location.objects.filter(parent=self.location))
- ).select_related().order_by('ap_id', 'ap__apclass__kind').distinct("ap")
+ ).filter(
+ pub_date__range=(timeago,timepadding)
+ ).order_by('ap_id', 'ap__apclass__kind').distinct("ap")
related = []
for obj in self.object.related.all():
model = apps.get_model(obj.model_name.app_label, obj.model_name.model)