From ddb3436275d3f02183f515c38cd3193cd1dfe2f4 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 13 Nov 2022 18:42:47 -0700 Subject: Boosting! Incoming, anyway. --- activities/views/timelines.py | 46 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'activities/views') diff --git a/activities/views/timelines.py b/activities/views/timelines.py index 76cf018..9be988d 100644 --- a/activities/views/timelines.py +++ b/activities/views/timelines.py @@ -33,15 +33,15 @@ class Home(FormView): def get_context_data(self): context = super().get_context_data() - context["timeline_posts"] = [ - te.subject_post - for te in TimelineEvent.objects.filter( + context["events"] = ( + TimelineEvent.objects.filter( identity=self.request.identity, - type=TimelineEvent.Types.post, + type__in=[TimelineEvent.Types.post, TimelineEvent.Types.boost], ) .select_related("subject_post", "subject_post__author") .order_by("-created")[:100] - ] + ) + context["current_page"] = "home" return context @@ -54,6 +54,22 @@ class Home(FormView): return redirect(".") +@method_decorator(identity_required, name="dispatch") +class Local(TemplateView): + + template_name = "activities/local.html" + + def get_context_data(self): + context = super().get_context_data() + context["posts"] = ( + Post.objects.filter(visibility=Post.Visibilities.public, author__local=True) + .select_related("author") + .order_by("-created")[:100] + ) + context["current_page"] = "local" + return context + + @method_decorator(identity_required, name="dispatch") class Federated(TemplateView): @@ -61,10 +77,28 @@ class Federated(TemplateView): def get_context_data(self): context = super().get_context_data() - context["timeline_posts"] = ( + context["posts"] = ( Post.objects.filter(visibility=Post.Visibilities.public) .select_related("author") .order_by("-created")[:100] ) context["current_page"] = "federated" return context + + +@method_decorator(identity_required, name="dispatch") +class Notifications(TemplateView): + + template_name = "activities/notifications.html" + + def get_context_data(self): + context = super().get_context_data() + context["events"] = ( + TimelineEvent.objects.filter( + identity=self.request.identity, + ) + .exclude(type__in=[TimelineEvent.Types.post, TimelineEvent.Types.boost]) + .select_related("subject_post", "subject_post__author", "subject_identity") + ) + context["current_page"] = "notifications" + return context -- cgit v1.2.3