From 954cebadf4dae1208cc7cde35b0ed2a07a64b1d7 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 18 Mar 2024 08:34:31 -0500 Subject: sight: added a sortable table to birds of the year --- app/sightings/templates/sightings/year-list.html | 56 ++++++++++++++++++++++++ app/sightings/views.py | 10 ++++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 app/sightings/templates/sightings/year-list.html diff --git a/app/sightings/templates/sightings/year-list.html b/app/sightings/templates/sightings/year-list.html new file mode 100644 index 0000000..2d75a56 --- /dev/null +++ b/app/sightings/templates/sightings/year-list.html @@ -0,0 +1,56 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load pagination_tags %} + +{% block pagetitle %}Luxagraf | Birding {{year}} List{% endblock %} +{% block metadescription %}Birding {{year}} List{% endblock %} +{%block bodyid%}id="birds"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +
+
+
+
    {% for object in object_list %} +
  • + {% endfor %}
+
+{% block primary %} +
+
+

Birds of {{year}}

+

Current Total: {{object_list|length}}

+
+ + + + + + + + +{% for object in object_list %} + + + + + +{% endfor %} + +
+
Species
+
+
Location
+
+
Date
+
+ {{object.ap|safe|smartypants|widont}} + + {{object.location}} + + {{object.pub_date}} +
+ +
+{% endblock %} +{% block js %} + +{% endblock%} diff --git a/app/sightings/views.py b/app/sightings/views.py index 24c341d..c4aab46 100644 --- a/app/sightings/views.py +++ b/app/sightings/views.py @@ -1,6 +1,7 @@ from django.views.generic.detail import DetailView from django.views.generic import ListView from django.contrib.auth.models import User +from django.utils import timezone from utils.views import PaginatedListView,LuxDetailView from .models import AP, Sighting, FieldNote @@ -43,11 +44,18 @@ class NotLifeListView(ListView): class YearListView(ListView): - template_name = 'sightings/life-list.html' + 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') + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(YearListView, self).get_context_data(**kwargs) + context['year'] = timezone.now().year + return context + + class SightingListUserView(PaginatedListView): template_name = 'archives/sightings.html' -- cgit v1.2.3-70-g09d2