From c588567c8698700cd347d9b8f884a7967890aa58 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 16 Dec 2022 17:39:10 -0700 Subject: [PATCH] Add follow times --- activities/views/follows.py | 24 ++++++++++++++++++------ static/css/style.css | 6 ++++++ templates/activities/follows.html | 2 ++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/activities/views/follows.py b/activities/views/follows.py index 5e14740..a8f787a 100644 --- a/activities/views/follows.py +++ b/activities/views/follows.py @@ -33,21 +33,33 @@ class Follows(ListView): state__in=FollowStates.group_active(), ).order_by("-created") + def follows_to_identities(self, follows, attr): + """ + Turns a list of follows into a list of identities (ith the + follow creation date preserved on them. + """ + result = [] + for follow in follows: + identity = getattr(follow, attr) + identity.follow_date = follow.state_changed + result.append(identity) + return result + def get_context_data(self): context = super().get_context_data() # Go work out if any of these people also follow us/are followed if self.inbound: - context["page_obj"].object_list = [ - follow.source for follow in context["page_obj"] - ] + context["page_obj"].object_list = self.follows_to_identities( + context["page_obj"], "source" + ) identity_ids = [identity.id for identity in context["page_obj"]] context["outbound_ids"] = Follow.objects.filter( source=self.request.identity, target_id__in=identity_ids ).values_list("target_id", flat=True) else: - context["page_obj"].object_list = [ - follow.target for follow in context["page_obj"] - ] + context["page_obj"].object_list = self.follows_to_identities( + context["page_obj"], "target" + ) identity_ids = [identity.id for identity in context["page_obj"]] context["inbound_ids"] = Follow.objects.filter( target=self.request.identity, source_id__in=identity_ids diff --git a/static/css/style.css b/static/css/style.css index 05e3812..abfa61c 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -396,6 +396,12 @@ body.no-sidebar .right-column { background: var(--color-delete); } +.icon-menu .option time { + float: right; + color: var(--color-text-duller); + margin: 14px 0 0 0; +} + .handle { vertical-align: middle; display: inline-block; diff --git a/templates/activities/follows.html b/templates/activities/follows.html index 5ee695f..eae344b 100644 --- a/templates/activities/follows.html +++ b/templates/activities/follows.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load activity_tags %} {% block subtitle %}Follows{% endblock %} @@ -27,6 +28,7 @@ {% if identity.id in inbound_ids %} Follows You {% endif %} + {% empty %}

You have no follows.