diff options
Diffstat (limited to 'app/sightings')
-rw-r--r-- | app/sightings/admin.py | 2 | ||||
-rw-r--r-- | app/sightings/templates/sightings/year-list.html | 5 | ||||
-rw-r--r-- | app/sightings/views.py | 8 |
3 files changed, 12 insertions, 3 deletions
diff --git a/app/sightings/admin.py b/app/sightings/admin.py index e3cfb64..610260e 100644 --- a/app/sightings/admin.py +++ b/app/sightings/admin.py @@ -7,7 +7,6 @@ from utils.util import get_latlon from utils.widgets import CustomSelectMultiple, LGEntryForm from django.contrib.admin.options import FORMFIELD_FOR_DBFIELD_DEFAULTS - @admin.register(APClass) class APClassAdmin(admin.ModelAdmin): list_display = ('common_name', 'scientific_name', 'kind') @@ -103,6 +102,7 @@ class SightingAdmin(OSMGeoAdmin): list_filter = (('location', admin.RelatedOnlyFieldListFilter), 'pub_date') list_display = ('ap', 'location', 'pub_date') search_fields = ['ap__common_name',] + autocomplete_fields = ["ap"] # options for OSM map Using custom ESRI topo map lat, lon = get_latlon() default_lon = lon diff --git a/app/sightings/templates/sightings/year-list.html b/app/sightings/templates/sightings/year-list.html index 2d75a56..40abb89 100644 --- a/app/sightings/templates/sightings/year-list.html +++ b/app/sightings/templates/sightings/year-list.html @@ -4,6 +4,9 @@ {% block pagetitle %}Luxagraf | Birding {{year}} List{% endblock %} {% block metadescription %}Birding {{year}} List{% endblock %} +{%block extrahead%} +<link href="/media/sortable.min.css" rel="stylesheet" /> +{%endblock%} {%block bodyid%}id="birds"{%endblock%} {% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} <main class="archive-wrapper"> @@ -42,7 +45,7 @@ {{object.location}} </td> <td class="field-admin_url"> - {{object.pub_date}} + {{object.pub_date|date:"F d, Y"}} </td> </tr> {% endfor %} diff --git a/app/sightings/views.py b/app/sightings/views.py index c4aab46..6f536b6 100644 --- a/app/sightings/views.py +++ b/app/sightings/views.py @@ -4,6 +4,7 @@ from django.contrib.auth.models import User from django.utils import timezone from utils.views import PaginatedListView,LuxDetailView from .models import AP, Sighting, FieldNote +from django.db.models import Subquery class SightingListView(PaginatedListView): @@ -47,7 +48,12 @@ class YearListView(ListView): template_name = 'sightings/year-list.html' def get_queryset(self): - return Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap__id').distinct('ap') + qs = Sighting.objects.filter( + pk__in=Subquery( + Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap_id').distinct('ap').values('pk') + ) + ).order_by('-pub_date') + return qs #Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap__id','pub_date').distinct('ap') def get_context_data(self, **kwargs): # Call the base implementation first to get a context |