From eadf5cf4106fbaf6bd18bd7c19521addc60523e0 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Tue, 13 Jul 2021 21:25:17 -0700 Subject: [PATCH] Use shelved date for display I'm not sure if there's a better way to access this field, accessing via book.shelfbook__shelved_date in the template didn't seem to work --- bookwyrm/templates/user/shelf/shelf.html | 2 +- bookwyrm/views/shelf.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/user/shelf/shelf.html b/bookwyrm/templates/user/shelf/shelf.html index 2163db8c..01a7eee9 100644 --- a/bookwyrm/templates/user/shelf/shelf.html +++ b/bookwyrm/templates/user/shelf/shelf.html @@ -103,7 +103,7 @@ {% include 'snippets/authors.html' %} - {{ book.created_date|naturalday }} + {{ book.shelved_date|naturalday }} {% latest_read_through book user as read_through %} diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index 54097509..e9ad074d 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -2,7 +2,7 @@ from collections import namedtuple from django.db import IntegrityError -from django.db.models import OuterRef, Subquery +from django.db.models import OuterRef, Subquery, F from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator from django.http import HttpResponseBadRequest, HttpResponseNotFound @@ -69,7 +69,8 @@ class Shelf(View): reviews = privacy_filter(request.user, reviews) books = books.annotate( - rating=Subquery(reviews.values("rating")[:1]) + rating=Subquery(reviews.values("rating")[:1]), + shelved_date=F("shelfbook__shelved_date"), ).prefetch_related("authors") paginated = Paginator(