Add follow times
This commit is contained in:
parent
be377653fe
commit
c588567c86
@ -33,21 +33,33 @@ class Follows(ListView):
|
|||||||
state__in=FollowStates.group_active(),
|
state__in=FollowStates.group_active(),
|
||||||
).order_by("-created")
|
).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):
|
def get_context_data(self):
|
||||||
context = super().get_context_data()
|
context = super().get_context_data()
|
||||||
# Go work out if any of these people also follow us/are followed
|
# Go work out if any of these people also follow us/are followed
|
||||||
if self.inbound:
|
if self.inbound:
|
||||||
context["page_obj"].object_list = [
|
context["page_obj"].object_list = self.follows_to_identities(
|
||||||
follow.source for follow in context["page_obj"]
|
context["page_obj"], "source"
|
||||||
]
|
)
|
||||||
identity_ids = [identity.id for identity in context["page_obj"]]
|
identity_ids = [identity.id for identity in context["page_obj"]]
|
||||||
context["outbound_ids"] = Follow.objects.filter(
|
context["outbound_ids"] = Follow.objects.filter(
|
||||||
source=self.request.identity, target_id__in=identity_ids
|
source=self.request.identity, target_id__in=identity_ids
|
||||||
).values_list("target_id", flat=True)
|
).values_list("target_id", flat=True)
|
||||||
else:
|
else:
|
||||||
context["page_obj"].object_list = [
|
context["page_obj"].object_list = self.follows_to_identities(
|
||||||
follow.target for follow in context["page_obj"]
|
context["page_obj"], "target"
|
||||||
]
|
)
|
||||||
identity_ids = [identity.id for identity in context["page_obj"]]
|
identity_ids = [identity.id for identity in context["page_obj"]]
|
||||||
context["inbound_ids"] = Follow.objects.filter(
|
context["inbound_ids"] = Follow.objects.filter(
|
||||||
target=self.request.identity, source_id__in=identity_ids
|
target=self.request.identity, source_id__in=identity_ids
|
||||||
|
@ -396,6 +396,12 @@ body.no-sidebar .right-column {
|
|||||||
background: var(--color-delete);
|
background: var(--color-delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-menu .option time {
|
||||||
|
float: right;
|
||||||
|
color: var(--color-text-duller);
|
||||||
|
margin: 14px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
.handle {
|
.handle {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load activity_tags %}
|
||||||
|
|
||||||
{% block subtitle %}Follows{% endblock %}
|
{% block subtitle %}Follows{% endblock %}
|
||||||
|
|
||||||
@ -27,6 +28,7 @@
|
|||||||
{% if identity.id in inbound_ids %}
|
{% if identity.id in inbound_ids %}
|
||||||
<span class="pill">Follows You</span>
|
<span class="pill">Follows You</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<time>{{ identity.follow_date | timedeltashort }} ago</time>
|
||||||
</a>
|
</a>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p class="option empty">You have no follows.</p>
|
<p class="option empty">You have no follows.</p>
|
||||||
|
Reference in New Issue
Block a user