Repository: bookwyrm-social/bookwyrm

Issue:
Make finding my comments and quotes easier
**Is your feature request related to a problem? Please describe.**
I sometimes want to look up a comment I made on a book or a quote.

**Describe the solution you'd like**
I think it would be useful to display my comments and quotes on book pages.

**Describe alternatives you've considered**
The only other option is to scroll through the home timeline or my profile page, as far as I'm aware.



Discussion:
This is sort of intentional -- I set up the book page to only show reviews so that comments and quotes could be posted in a way that felt more transient. I also delete my old posts on mastodon and twitter. But that's my personal preference for social media, not an objectively correct design principal.

A solution that comes to mind which I think balances both desires is to a tab on the book page, in the reviews region, for the current logged in user's comments and quotes on the book. That would make your posts about the book readily accessible, but only to you. Does that seem like it would satisfy what your concerns are?
Yes, I meant that it should only be visible for me. 🙂
I think quotes could, optionally, be public. I like how you can see author's quotes on GR and like them, and how you could link them to your profile either by liking them or creating them.

Resolving patch:
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py
--- a/bookwyrm/urls.py
+++ b/bookwyrm/urls.py
@@ -260,7 +260,12 @@
     re_path(r"^boost/(?P<status_id>\d+)/?$", views.Boost.as_view()),
     re_path(r"^unboost/(?P<status_id>\d+)/?$", views.Unboost.as_view()),
     # books
-    re_path(r"%s(.json)?/?$" % book_path, views.Book.as_view()),
+    re_path(r"%s(.json)?/?$" % book_path, views.Book.as_view(), name="book"),
+    re_path(
+        r"%s/(?P<user_statuses>review|comment|quote)/?$" % book_path,
+        views.Book.as_view(),
+        name="book-user-statuses",
+    ),
     re_path(r"%s/edit/?$" % book_path, views.EditBook.as_view()),
     re_path(r"%s/confirm/?$" % book_path, views.ConfirmEditBook.as_view()),
     re_path(r"^create-book/?$", views.EditBook.as_view()),
diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py
--- a/bookwyrm/views/books.py
+++ b/bookwyrm/views/books.py
@@ -28,7 +28,7 @@
 class Book(View):
     """ a book! this is the stuff """
 
-    def get(self, request, book_id):
+    def get(self, request, book_id, user_statuses=False):
         """ info about a book """
         try:
             book = models.Book.objects.select_subclasses().get(id=book_id)
@@ -40,22 +40,39 @@ def get(self, request, book_id):
 
         if isinstance(book, models.Work):
             book = book.get_default_edition()
-        if not book:
+        if not book or not book.parent_work:
             return HttpResponseNotFound()
 
         work = book.parent_work
-        if not work:
-            return HttpResponseNotFound()
 
         # all reviews for the book
-        reviews = models.Review.objects.filter(book__in=work.editions.all())
-        reviews = privacy_filter(request.user, reviews)
+        reviews = privacy_filter(
+            request.user, models.Review.objects.filter(book__in=work.editions.all())
+        )
 
         # the reviews to show
-        paginated = Paginator(
-            reviews.exclude(Q(content__isnull=True) | Q(content="")), PAGE_LENGTH
-        )
-        reviews_page = paginated.get_page(request.GET.get("page"))
+        if user_statuses and request.user.is_authenticated:
+            if user_statuses == "review":
+                queryset = book.review_set
+            elif user_statuses == "comment":
+                queryset = book.comment_set
+            else:
+                queryset = book.quotation_set
+            queryset = queryset.filter(user=request.user)
+        else:
+            queryset = reviews.exclude(Q(content__isnull=True) | Q(content=""))
+        paginated = Paginator(queryset, PAGE_LENGTH)
+
+        data = {
+            "book": book,
+            "statuses": paginated.get_page(request.GET.get("page")),
+            "review_count": reviews.count(),
+            "ratings": reviews.filter(Q(content__isnull=True) | Q(content="")),
+            "rating": reviews.aggregate(Avg("rating"))["rating__avg"],
+            "lists": privacy_filter(
+                request.user, book.list_set.filter(listitem__approved=True)
+            ),
+        }
 
         if request.user.is_authenticated:
             readthroughs = models.ReadThrough.objects.filter(
@@ -67,29 +84,24 @@ def get(self, request, book_id):
                 readthrough.progress_updates = (
                     readthrough.progressupdate_set.all().order_by("-updated_date")
                 )
+            data["readthroughs"] = readthroughs
 
-            user_shelves = models.ShelfBook.objects.filter(user=request.user, book=book)
+            data["user_shelves"] = models.ShelfBook.objects.filter(
+                user=request.user, book=book
+            )
 
-            other_edition_shelves = models.ShelfBook.objects.filter(
+            data["other_edition_shelves"] = models.ShelfBook.objects.filter(
                 ~Q(book=book),
                 user=request.user,
                 book__parent_work=book.parent_work,
             )
 
-        data = {
-            "book": book,
-            "reviews": reviews_page,
-            "review_count": reviews.count(),
-            "ratings": reviews.filter(Q(content__isnull=True) | Q(content="")),
-            "rating": reviews.aggregate(Avg("rating"))["rating__avg"],
-            "lists": privacy_filter(
-                request.user, book.list_set.filter(listitem__approved=True)
-            ),
-            "user_shelves": user_shelves,
-            "other_edition_shelves": other_edition_shelves,
-            "readthroughs": readthroughs,
-            "path": "/book/%s" % book_id,
-        }
+            data["user_statuses"] = {
+                "review_count": book.review_set.filter(user=request.user).count(),
+                "comment_count": book.comment_set.filter(user=request.user).count(),
+                "quotation_count": book.quotation_set.filter(user=request.user).count(),
+            }
+
         return TemplateResponse(request, "book/book.html", data)
 
 


Test patch: