summaryrefslogtreecommitdiffstats
path: root/activities/views
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-16 06:53:39 -0700
committerAndrew Godwin2022-11-16 13:53:40 -0700
commit495e955378d62dc439c4c210785e5d401bc77f64 (patch)
tree859813b06314f387470295e752d1f1b3828830a7 /activities/views
parent906ed2f27c9105dbd78f416930f1aa2b49497567 (diff)
downloadtakahe-495e955378d62dc439c4c210785e5d401bc77f64.tar.gz
takahe-495e955378d62dc439c4c210785e5d401bc77f64.tar.bz2
takahe-495e955378d62dc439c4c210785e5d401bc77f64.zip
Tag and visibility handling
Diffstat (limited to 'activities/views')
-rw-r--r--activities/views/posts.py49
-rw-r--r--activities/views/timelines.py11
2 files changed, 50 insertions, 10 deletions
diff --git a/activities/views/posts.py b/activities/views/posts.py
index ece7cf3..3ee35cc 100644
--- a/activities/views/posts.py
+++ b/activities/views/posts.py
@@ -1,13 +1,15 @@
+from django import forms
from django.shortcuts import get_object_or_404, redirect, render
+from django.template.defaultfilters import linebreaks_filter
from django.utils.decorators import method_decorator
-from django.views.generic import TemplateView, View
+from django.views.generic import FormView, TemplateView, View
-from activities.models import PostInteraction, PostInteractionStates
+from activities.models import Post, PostInteraction, PostInteractionStates
from users.decorators import identity_required
from users.shortcuts import by_handle_or_404
-class Post(TemplateView):
+class Individual(TemplateView):
template_name = "activities/post.html"
@@ -100,3 +102,44 @@ class Boost(View):
},
)
return redirect(post.urls.view)
+
+
+@method_decorator(identity_required, name="dispatch")
+class Compose(FormView):
+
+ template_name = "activities/compose.html"
+
+ class form_class(forms.Form):
+ text = forms.CharField(
+ widget=forms.Textarea(
+ attrs={
+ "placeholder": "What's on your mind?",
+ },
+ )
+ )
+ visibility = forms.ChoiceField(
+ choices=[
+ (Post.Visibilities.public, "Public"),
+ (Post.Visibilities.unlisted, "Unlisted"),
+ (Post.Visibilities.followers, "Followers & Mentioned Only"),
+ (Post.Visibilities.mentioned, "Mentioned Only"),
+ ],
+ )
+ content_warning = forms.CharField(
+ required=False,
+ widget=forms.TextInput(
+ attrs={
+ "placeholder": "Content Warning",
+ },
+ ),
+ help_text="Optional - Post will be hidden behind this text until clicked",
+ )
+
+ def form_valid(self, form):
+ Post.create_local(
+ author=self.request.identity,
+ content=linebreaks_filter(form.cleaned_data["text"]),
+ summary=form.cleaned_data.get("content_warning"),
+ visibility=form.cleaned_data["visibility"],
+ )
+ return redirect("/")
diff --git a/activities/views/timelines.py b/activities/views/timelines.py
index c59c3b6..45a0c30 100644
--- a/activities/views/timelines.py
+++ b/activities/views/timelines.py
@@ -95,12 +95,9 @@ class Notifications(TemplateView):
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["events"] = TimelineEvent.objects.filter(
+ identity=self.request.identity,
+ type__in=[TimelineEvent.Types.mentioned, TimelineEvent.Types.boosted],
+ ).select_related("subject_post", "subject_post__author", "subject_identity")
context["current_page"] = "notifications"
return context