diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/posts/views/jrnl_views.py | 7 | ||||
-rw-r--r-- | app/sightings/admin.py | 2 |
2 files changed, 7 insertions, 2 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) diff --git a/app/sightings/admin.py b/app/sightings/admin.py index 6b47f90..e3cfb64 100644 --- a/app/sightings/admin.py +++ b/app/sightings/admin.py @@ -100,7 +100,7 @@ class APAdmin(admin.ModelAdmin): @admin.register(Sighting) class SightingAdmin(OSMGeoAdmin): - list_filter = (('location', admin.RelatedOnlyFieldListFilter),) + list_filter = (('location', admin.RelatedOnlyFieldListFilter), 'pub_date') list_display = ('ap', 'location', 'pub_date') search_fields = ['ap__common_name',] # options for OSM map Using custom ESRI topo map |