diff options
author | Andrew Godwin | 2022-11-16 23:00:10 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-16 23:00:10 -0700 |
commit | 716d8a766ae0c4e2539f2df601269a3203bcd715 (patch) | |
tree | 6fca650c5960b06494ba322d4621727b81bd4fa0 /activities/views | |
parent | b13c239213147b7acae4060aff35640d625b5169 (diff) | |
download | takahe-716d8a766ae0c4e2539f2df601269a3203bcd715.tar.gz takahe-716d8a766ae0c4e2539f2df601269a3203bcd715.tar.bz2 takahe-716d8a766ae0c4e2539f2df601269a3203bcd715.zip |
Show post images
Diffstat (limited to 'activities/views')
-rw-r--r-- | activities/views/posts.py | 4 | ||||
-rw-r--r-- | activities/views/timelines.py | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activities/views/posts.py b/activities/views/posts.py index 3ee35cc..7b93e42 100644 --- a/activities/views/posts.py +++ b/activities/views/posts.py @@ -36,7 +36,9 @@ class Like(View): def post(self, request, handle, post_id): identity = by_handle_or_404(self.request, handle, local=False) - post = get_object_or_404(identity.posts, pk=post_id) + post = get_object_or_404( + identity.posts.prefetch_related("attachments"), pk=post_id + ) if self.undo: # Undo any likes on the post for interaction in PostInteraction.objects.filter( diff --git a/activities/views/timelines.py b/activities/views/timelines.py index 45a0c30..ae01a45 100644 --- a/activities/views/timelines.py +++ b/activities/views/timelines.py @@ -39,6 +39,7 @@ class Home(FormView): type__in=[TimelineEvent.Types.post, TimelineEvent.Types.boost], ) .select_related("subject_post", "subject_post__author") + .prefetch_related("subject_post__attachments") .order_by("-created")[:100] ) context["interactions"] = PostInteraction.get_event_interactions( @@ -66,6 +67,7 @@ class Local(TemplateView): context["posts"] = ( Post.objects.filter(visibility=Post.Visibilities.public, author__local=True) .select_related("author") + .prefetch_related("attachments") .order_by("-created")[:100] ) context["current_page"] = "local" @@ -82,6 +84,7 @@ class Federated(TemplateView): context["posts"] = ( Post.objects.filter(visibility=Post.Visibilities.public) .select_related("author") + .prefetch_related("attachments") .order_by("-created")[:100] ) context["current_page"] = "federated" |