From 96bac9923ad0a7c2feb691183049151a596f51ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Fri, 28 Jul 2023 06:59:37 +0300
Subject: [PATCH 1/1] Update summary after deleting segments; unpublish empty
posts
model.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/model.py b/model.py
index 3ce1fc0..e4aeada 100644
--- a/model.py
+++ b/model.py
@@ -1419,8 +1419,18 @@ class Database:
cur.execute('DELETE FROM segments WHERE id=?', (segment.id,))
cur.execute('DELETE FROM crossrefs WHERE segment=?', (segment.id,))
self.commit()
post = self.get_post(id=segment.post)
if not post.is_draft:
self.update_post_summary(post)
if segment.type == Segment.POLL:
self.update_poll_tag(self.get_post(id=segment.post))
self.update_poll_tag(post)
self.unpublish_if_empty(post)
if not post.is_draft and not post.title and post.num_cmts == 0 and \
len(self.get_segments(post)) == 0:
self.unpublish_post(post)
def update_segment_crossrefs(self, segment: Segment):
if segment.type == Segment.TEXT:
@@ -1502,6 +1512,9 @@ class Database:
pos += 1
self.commit()
if not post.is_draft:
self.update_post_summary(post)
def modify_vote(self, user: User, segment: Segment):
cur = self.conn.cursor()
@@ -1783,6 +1796,7 @@ class Database:
self.commit()
if title != None and not post.is_draft:
self.update_post_summary(post)
self.unpublish_if_empty(post)
def notify_mentioned(self, post, content, old_content=None):
names = parse_at_names(content)
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).