diff --git a/bookwyrm/templates/feed/suggested_books.html b/bookwyrm/templates/feed/suggested_books.html
new file mode 100644
index 00000000..d559c6ca
--- /dev/null
+++ b/bookwyrm/templates/feed/suggested_books.html
@@ -0,0 +1,82 @@
+{% load i18n %}
+{% load cache %}
+{% load bookwyrm_tags %}
+
+{% cache None suggested_books request.user.id %}
+{% suggested_books as suggested_books %}
+
+ {% trans "Your Books" %}
+ {% if not suggested_books %}
+ {% trans "There are no books here right now! Try searching for a book to get started" %}
+ {% else %}
+ {% with active_book=request.GET.book %}
+
+
+ {% for shelf in suggested_books %}
+ {% with shelf_counter=forloop.counter %}
+ {% for book in shelf.books %}
+
+
+
+
+ {% include 'snippets/create_status.html' with book=book %}
+
+
+ {% endfor %}
+ {% endwith %}
+ {% endfor %}
+
+ {% endwith %}
+ {% endif %}
+
+{% endcache %}
diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py
index 9d84d1ff..c15df090 100644
--- a/bookwyrm/templatetags/bookwyrm_tags.py
+++ b/bookwyrm/templatetags/bookwyrm_tags.py
@@ -3,6 +3,7 @@ from django import template
from django.db.models import Avg
from bookwyrm import models
+from bookwyrm.views.feed import get_suggested_books
register = template.Library()
@@ -115,3 +116,11 @@ def mutuals_count(context, user):
if not viewer.is_authenticated:
return None
return user.followers.filter(followers=viewer).count()
+
+
+@register.simple_tag(takes_context=True)
+def suggested_books(context):
+ """get books for suggested books panel"""
+ # this happens here instead of in the view so that the template snippet can
+ # be cached in the template
+ return get_suggested_books(context["request"].user)
diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py
index f6f9fb37..e060ae61 100644
--- a/bookwyrm/views/feed.py
+++ b/bookwyrm/views/feed.py
@@ -223,7 +223,6 @@ def feed_page_data(user):
goal = models.AnnualGoal.objects.filter(user=user, year=timezone.now().year).first()
return {
- "suggested_books": get_suggested_books(user),
"goal": goal,
"goal_form": forms.GoalForm(),
}
diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py
index 73bc0b83..c7eda10e 100644
--- a/bookwyrm/views/reading.py
+++ b/bookwyrm/views/reading.py
@@ -47,10 +47,11 @@ class ReadingStatus(View):
return HttpResponseBadRequest()
# invalidate the template cache
- cache_key = make_template_fragment_key(
- "shelve_button", [request.user.id, book_id]
- )
- cache.delete(cache_key)
+ cache_keys = [
+ make_template_fragment_key("shelve_button", [request.user.id, book_id]),
+ make_template_fragment_key("suggested_books", [request.user.id]),
+ ]
+ cache.delete_many(cache_keys)
desired_shelf = get_object_or_404(
models.Shelf, identifier=identifier, user=request.user