summaryrefslogtreecommitdiff
path: root/app/fieldnotes/views.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-08-07 15:57:20 -0400
committerluxagraf <sng@luxagraf.net>2020-08-07 15:57:20 -0400
commitfe912293dcd912cac7f24a488b4faf8f5b275de7 (patch)
tree0e6b05e4ac5cdb51cf46665d87d0fa2bec9352e9 /app/fieldnotes/views.py
parentd757203bae35697b739e177183ada7198c495d52 (diff)
fixed fieldnotes to include images and build them into archives
Diffstat (limited to 'app/fieldnotes/views.py')
-rw-r--r--app/fieldnotes/views.py56
1 files changed, 48 insertions, 8 deletions
diff --git a/app/fieldnotes/views.py b/app/fieldnotes/views.py
index f22cfeb..d9b05b2 100644
--- a/app/fieldnotes/views.py
+++ b/app/fieldnotes/views.py
@@ -8,6 +8,7 @@ from utils.views import PaginatedListView, LuxDetailView
from .models import FieldNote
from photos.models import LuxImage
+
class FieldNoteListView(PaginatedListView):
"""
Main Archive of Field Notes, which also includes photo posts
@@ -49,15 +50,54 @@ class FieldNoteDetailViewTXT(FieldNoteDetailView):
template_name = "jrnl/entry.txt"
-class FieldNoteYearArchiveView(YearArchiveView):
- queryset = FieldNote.objects.filter(status=1)
- date_field = "pub_date"
+class FieldNoteYearArchiveView(FieldNoteListView):
template_name = "fieldnotes/fieldnote_archive_list_date.html"
- make_object_list = True
+
+ def get_queryset(self):
+ """
+ Return a list of Notes and Photos combined
+ in reverse chronological order
+ """
+ qs1 = FieldNote.objects.filter(
+ status=1,
+ pub_date__year=self.kwargs['year'],
+ ).order_by('-pub_date').prefetch_related('location')
+ qs2 = LuxImage.objects.filter(
+ is_public=True,
+ title__startswith="fn_",
+ pub_date__year=self.kwargs['year'],
+ ).prefetch_related('sizes').prefetch_related('location')
+ result_list = sorted(
+ chain(qs1, qs2),
+ key=attrgetter('pub_date')
+ )
+ return result_list[:: -1]
-class FieldNoteMonthArchiveView(MonthArchiveView):
- queryset = FieldNote.objects.filter(status=1)
- date_field = "pub_date"
- make_object_list = True
+class FieldNoteMonthArchiveView(FieldNoteListView):
template_name = "fieldnotes/fieldnote_archive_list_date.html"
+
+
+ def get_queryset(self):
+ """
+ Return a list of Notes and Photos combined
+ in reverse chronological order
+ """
+ qs1 = FieldNote.objects.filter(
+ status=1,
+ pub_date__year=self.kwargs['year'],
+ pub_date__month=self.kwargs['month']
+ ).order_by('-pub_date').prefetch_related('location')
+ qs2 = LuxImage.objects.filter(
+ is_public=True,
+ title__startswith="fn_",
+ pub_date__year=self.kwargs['year'],
+ pub_date__month=self.kwargs['month']
+ ).prefetch_related('sizes').prefetch_related('location')
+
+ result_list = sorted(
+ chain(qs1, qs2),
+ key=attrgetter('pub_date')
+ )
+ return result_list[:: -1]
+