summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2024-03-18 08:34:31 -0500
committerluxagraf <sng@luxagraf.net>2024-03-18 08:34:31 -0500
commit954cebadf4dae1208cc7cde35b0ed2a07a64b1d7 (patch)
tree59364723a258ce7942957f041f660f17aa1f2d95
parent21795671955fb4d675b740bba73b4d4f90d37739 (diff)
sight: added a sortable table to birds of the year
-rw-r--r--app/sightings/templates/sightings/year-list.html56
-rw-r--r--app/sightings/views.py10
2 files changed, 65 insertions, 1 deletions
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 %}
+ <main class="archive-wrapper">
+ <div class="archive-intro">
+ <div>
+ <ul class="archive-list">{% for object in object_list %}
+ <li class=""></li>
+ {% endfor %}</ul>
+ </main>
+{% block primary %}
+<main class="content">
+ <div class="archive-intro">
+ <h1>Birds of {{year}}</h1>
+ <h3>Current Total: {{object_list|length}}</h3>
+ </div>
+<table class="sortable" id="result_list">
+<thead>
+<tr>
+<th scope="col" class="sortable column-title">
+ <div class="text"><span>Species</span></div>
+</th>
+<th scope="col" class="sortable column-title">
+ <div class="text"><span>Location</span></div>
+</th>
+<th scope="col" class="column-admin_url">
+ <div class="text"><span>Date</span></div>
+</th>
+</tr>
+</thead>
+<tbody>{% for object in object_list %}
+<tr>
+ <td class="field-title">
+ <a href="{{object.ap.get_absolute_url}}" title="{{object.ap}}">{{object.ap|safe|smartypants|widont}}</a>
+ </td>
+ <td class="field-admin_url">
+ {{object.location}}
+ </td>
+ <td class="field-admin_url">
+ {{object.pub_date}}
+ </td>
+</tr>
+{% endfor %}
+</tbody>
+</table>
+</div>
+</main>
+{% endblock %}
+{% block js %}
+<script src="/media/sortable.min.js"></script>
+{% 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'