diff --git a/.github/workflows/django-tests.yml b/.github/workflows/django-tests.yml
index 4968b40c..00e08dad 100644
--- a/.github/workflows/django-tests.yml
+++ b/.github/workflows/django-tests.yml
@@ -47,7 +47,7 @@ jobs:
CELERY_BROKER: ""
REDIS_BROKER_PORT: 6379
REDIS_BROKER_PASSWORD: beep
- USE_LOCAL_CACHE: true
+ USE_DUMMY_CACHE: true
FLOWER_PORT: 8888
EMAIL_HOST: "smtp.mailgun.org"
EMAIL_PORT: 587
diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py
index 57717fb9..5b69e378 100644
--- a/bookwyrm/settings.py
+++ b/bookwyrm/settings.py
@@ -120,7 +120,13 @@ STREAMS = [
]
# Redis cache backend
-if not env("USE_LOCAL_CACHE", False):
+if env("USE_DUMMY_CACHE", False):
+ CACHES = {
+ "default": {
+ "BACKEND": "django.core.cache.backends.dummy.DummyCache",
+ }
+ }
+else:
# pylint: disable=line-too-long
CACHES = {
"default": {
diff --git a/bookwyrm/templates/directory/sort_filter.html b/bookwyrm/templates/directory/sort_filter.html
index c7c19f6f..34436601 100644
--- a/bookwyrm/templates/directory/sort_filter.html
+++ b/bookwyrm/templates/directory/sort_filter.html
@@ -3,10 +3,12 @@
{% block filter %}
-
-
+
+
+
+
{% endblock %}
diff --git a/bookwyrm/templates/settings/users/server_filter.html b/bookwyrm/templates/settings/users/server_filter.html
index 2a4b89fd..5879f748 100644
--- a/bookwyrm/templates/settings/users/server_filter.html
+++ b/bookwyrm/templates/settings/users/server_filter.html
@@ -3,5 +3,7 @@
{% block filter %}
-
+
+
+
{% endblock %}
diff --git a/bookwyrm/templates/settings/users/username_filter.html b/bookwyrm/templates/settings/users/username_filter.html
index d7da033a..343e61c8 100644
--- a/bookwyrm/templates/settings/users/username_filter.html
+++ b/bookwyrm/templates/settings/users/username_filter.html
@@ -3,6 +3,7 @@
{% block filter %}
-
+
+
+
{% endblock %}
-
diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html
index 174c379f..5cbcef20 100644
--- a/bookwyrm/templates/snippets/status/layout.html
+++ b/bookwyrm/templates/snippets/status/layout.html
@@ -1,7 +1,6 @@
{% extends 'components/card.html' %}
{% load i18n %}
{% load utilities %}
-{% load cache %}
{% block card-header %}
{% endif %}
- {% endcache %}
{% else %}
diff --git a/bookwyrm/templates/snippets/status/status_options.html b/bookwyrm/templates/snippets/status/status_options.html
index 854d4779..fdf8ac14 100644
--- a/bookwyrm/templates/snippets/status/status_options.html
+++ b/bookwyrm/templates/snippets/status/status_options.html
@@ -20,17 +20,21 @@
{% if status.status_type != 'GeneratedNote' and status.status_type != 'Rating' %}
-
- {% trans "Edit" %}
-
+
+
+ {% trans "Edit" %}
+
+
{% endif %}
{% else %}
{# things you can do to other people's statuses #}
-
- {% trans "Send direct message" %}
-
+
+
+ {% trans "Send direct message" %}
+
+
{% include 'snippets/report_button.html' with user=status.user status=status %}
diff --git a/bookwyrm/templatetags/interaction.py b/bookwyrm/templatetags/interaction.py
index 64c91f89..90309aaf 100644
--- a/bookwyrm/templatetags/interaction.py
+++ b/bookwyrm/templatetags/interaction.py
@@ -1,5 +1,7 @@
""" template filters for status interaction buttons """
from django import template
+from django.core.cache import cache
+
from bookwyrm import models
@@ -9,13 +11,21 @@ register = template.Library()
@register.filter(name="liked")
def get_user_liked(user, status):
"""did the given user fav a status?"""
- return models.Favorite.objects.filter(user=user, status=status).exists()
+ return cache.get_or_set(
+ f"fav-{user.id}-{status.id}",
+ models.Favorite.objects.filter(user=user, status=status).exists(),
+ 259200,
+ )
@register.filter(name="boosted")
def get_user_boosted(user, status):
"""did the given user fav a status?"""
- return status.boosters.filter(user=user).exists()
+ return cache.get_or_set(
+ f"boost-{user.id}-{status.id}",
+ status.boosters.filter(user=user).exists(),
+ 259200,
+ )
@register.filter(name="saved")
diff --git a/bookwyrm/views/interaction.py b/bookwyrm/views/interaction.py
index 9e897beb..f59271bd 100644
--- a/bookwyrm/views/interaction.py
+++ b/bookwyrm/views/interaction.py
@@ -1,7 +1,6 @@
""" boosts and favs """
from django.contrib.auth.decorators import login_required
from django.core.cache import cache
-from django.core.cache.utils import make_template_fragment_key
from django.db import IntegrityError
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound
from django.shortcuts import redirect
@@ -19,7 +18,7 @@ class Favorite(View):
def post(self, request, status_id):
"""create a like"""
- clear_cache(request.user.id, status_id)
+ cache.delete(f"fav-{request.user.id}-{status_id}")
status = models.Status.objects.get(id=status_id)
try:
models.Favorite.objects.create(status=status, user=request.user)
@@ -38,6 +37,7 @@ class Unfavorite(View):
def post(self, request, status_id):
"""unlike a status"""
+ cache.delete(f"fav-{request.user.id}-{status_id}")
status = models.Status.objects.get(id=status_id)
try:
favorite = models.Favorite.objects.get(status=status, user=request.user)
@@ -46,7 +46,6 @@ class Unfavorite(View):
return HttpResponseNotFound()
favorite.delete()
- clear_cache(request.user.id, status_id)
if is_api_request(request):
return HttpResponse()
return redirect(request.headers.get("Referer", "/"))
@@ -58,6 +57,7 @@ class Boost(View):
def post(self, request, status_id):
"""boost a status"""
+ cache.delete(f"boost-{request.user.id}-{status_id}")
status = models.Status.objects.get(id=status_id)
# is it boostable?
if not status.boostable:
@@ -74,7 +74,6 @@ class Boost(View):
privacy=status.privacy,
user=request.user,
)
- clear_cache(request.user.id, status_id)
if is_api_request(request):
return HttpResponse()
return redirect(request.headers.get("Referer", "/"))
@@ -86,19 +85,13 @@ class Unboost(View):
def post(self, request, status_id):
"""boost a status"""
+ cache.delete(f"boost-{request.user.id}-{status_id}")
status = models.Status.objects.get(id=status_id)
boost = models.Boost.objects.filter(
boosted_status=status, user=request.user
).first()
boost.delete()
- clear_cache(request.user.id, status_id)
if is_api_request(request):
return HttpResponse()
return redirect(request.headers.get("Referer", "/"))
-
-
-def clear_cache(user_id, status_id):
- """clear template cache"""
- cache_key = make_template_fragment_key("interact", [user_id, status_id])
- cache.delete(cache_key)