summaryrefslogtreecommitdiffstats
path: root/activities/views
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-27 12:09:08 -0700
committerAndrew Godwin2022-11-27 12:09:08 -0700
commit8e9e3ecf6935db84bbc731252f592795675de685 (patch)
treeeb3f690cdc7504b3f8fc2da716c1bbfc4bacc36c /activities/views
parent6c7ddedd342553b53dd98c8de9cbe9e8e2e8cd7c (diff)
downloadtakahe-8e9e3ecf6935db84bbc731252f592795675de685.tar.gz
takahe-8e9e3ecf6935db84bbc731252f592795675de685.tar.bz2
takahe-8e9e3ecf6935db84bbc731252f592795675de685.zip
Some cleanup around editing
Diffstat (limited to 'activities/views')
-rw-r--r--activities/views/posts.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/activities/views/posts.py b/activities/views/posts.py
index 5d7b0c9..083df30 100644
--- a/activities/views/posts.py
+++ b/activities/views/posts.py
@@ -2,7 +2,6 @@ from django import forms
from django.core.exceptions import PermissionDenied
from django.http import JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
-from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.generic import FormView, TemplateView, View
@@ -13,6 +12,7 @@ from activities.models import (
PostStates,
TimelineEvent,
)
+from core.html import html_to_plaintext
from core.ld import canonicalise
from core.models import Config
from users.decorators import identity_required
@@ -218,7 +218,7 @@ class Compose(FormView):
"id": self.post_obj.id,
"reply_to": self.reply_to.pk if self.reply_to else "",
"visibility": self.post_obj.visibility,
- "text": self.post_obj.content,
+ "text": html_to_plaintext(self.post_obj.content),
"content_warning": self.post_obj.summary,
}
)
@@ -236,11 +236,11 @@ class Compose(FormView):
post_id = form.cleaned_data.get("id")
if post_id:
post = get_object_or_404(self.request.identity.posts, pk=post_id)
- post.edited = timezone.now()
- post.content = form.cleaned_data["text"]
- post.summary = form.cleaned_data.get("content_warning")
- post.visibility = form.cleaned_data["visibility"]
- post.save()
+ post.edit_local(
+ content=form.cleaned_data["text"],
+ summary=form.cleaned_data.get("content_warning"),
+ visibility=form.cleaned_data["visibility"],
+ )
# Should there be a timeline event for edits?
# E.g. "@user edited #123"