summaryrefslogtreecommitdiffstats
path: root/users/views/follows.py
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-17 20:04:01 -0700
committerAndrew Godwin2022-11-17 20:04:01 -0700
commitb3072c81ba73a16381366960841b6c294cc1fa6e (patch)
tree707cf2f966dd030fc2a5e866f50711ab87a40870 /users/views/follows.py
parentadf2449d373bcd07e2b0ce557beeb1f49d1894e4 (diff)
downloadtakahe-b3072c81ba73a16381366960841b6c294cc1fa6e.tar.gz
takahe-b3072c81ba73a16381366960841b6c294cc1fa6e.tar.bz2
takahe-b3072c81ba73a16381366960841b6c294cc1fa6e.zip
Follows page
Diffstat (limited to 'users/views/follows.py')
-rw-r--r--users/views/follows.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/users/views/follows.py b/users/views/follows.py
new file mode 100644
index 0000000..9030efe
--- /dev/null
+++ b/users/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 = "settings/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),
+ }