diff --git a/activities/models/post.py b/activities/models/post.py index ff537040b..cc229f4d3 100644 --- a/activities/models/post.py +++ b/activities/models/post.py @@ -469,6 +469,7 @@ def stats_with_defaults(self): "likes": self.stats.get("likes", 0) if self.stats else 0, "boosts": self.stats.get("boosts", 0) if self.stats else 0, "replies": self.stats.get("replies", 0) if self.stats else 0, + "reactions": self.stats.get("reactions", {}) if self.stats else {}, } ### Local creation/editing ### @@ -618,7 +619,7 @@ def calculate_stats(self, save=True): ).count(), "replies": Post.objects.filter(in_reply_to=self.object_uri).count(), "reactions": { - row["value"]: row["count"] + row["value"] or "": row["count"] for row in self.interactions.filter( type=PostInteraction.Types.like, state__in=PostInteractionStates.group_active(), diff --git a/templates/activities/_post.html b/templates/activities/_post.html index a12eea9ef..1ff8a2079 100644 --- a/templates/activities/_post.html +++ b/templates/activities/_post.html @@ -78,10 +78,16 @@ {{ post.stats_with_defaults.replies|default:"0" }} - - - {{ post.stats_with_defaults.likes|default:"0" }} - + {% for reaction, count in post.stats_with_defaults.reactions.items %} + + {% if reaction %} + {{reaction}} + {% else %} + + {% endif %} + {{count}} + + {% endfor %} {{ post.stats_with_defaults.boosts|default:"0" }}