summaryrefslogtreecommitdiffstats
path: root/activities
diff options
context:
space:
mode:
authorTyler Kennedy2022-12-04 11:41:41 -0500
committerGitHub2022-12-04 09:41:41 -0700
commit6ce05296b01b1bd177e93b5ea3745fba5a5ff8f2 (patch)
treed589df378639dc8605a9f58b431ed37e0bc67b49 /activities
parent45b91e1a0ec3eea6305b7164057ed82845b5a8bb (diff)
downloadtakahe-6ce05296b01b1bd177e93b5ea3745fba5a5ff8f2.tar.gz
takahe-6ce05296b01b1bd177e93b5ea3745fba5a5ff8f2.tar.bz2
takahe-6ce05296b01b1bd177e93b5ea3745fba5a5ff8f2.zip
Make follows a top-level activity. (#94)
Diffstat (limited to 'activities')
-rw-r--r--activities/views/follows.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/activities/views/follows.py b/activities/views/follows.py
new file mode 100644
index 0000000..44d8adc
--- /dev/null
+++ b/activities/views/follows.py
@@ -0,0 +1,33 @@
+from django.utils.decorators import method_decorator
+from django.views.generic import TemplateView
+
+from users.decorators import identity_required
+from users.models import FollowStates
+
+
+@method_decorator(identity_required, name="dispatch")
+class FollowsPage(TemplateView):
+ """
+ Shows followers/follows.
+ """
+
+ template_name = "activities/follows.html"
+
+ def get_context_data(self):
+ # Gather all identities with a following relationship with us
+ identities = {}
+ for outbound_follow in self.request.identity.outbound_follows.filter(
+ state__in=FollowStates.group_active()
+ ):
+ identities.setdefault(outbound_follow.target, {})[
+ "outbound"
+ ] = outbound_follow
+ for inbound_follow in self.request.identity.inbound_follows.filter(
+ state__in=FollowStates.group_active()
+ ):
+ identities.setdefault(inbound_follow.source, {})["inbound"] = inbound_follow
+
+ return {
+ "section": "follows",
+ "identities": sorted(identities.items(), key=lambda i: i[0].username),
+ }