From 0218b24d77888519ed6a5f6029ab967ddfe2dd14 Mon Sep 17 00:00:00 2001 From: citrons Date: Tue, 17 Jun 2025 13:02:46 -0500 Subject: try to show the most recent non-deleted post requires db migration --- apioforum/db.py | 5 +++++ apioforum/forum.py | 3 ++- apioforum/templates/view_forum.html | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apioforum/db.py b/apioforum/db.py index 0305167..7f15950 100644 --- a/apioforum/db.py +++ b/apioforum/db.py @@ -245,6 +245,11 @@ ALTER TABLE forums ADD COLUMN updated TIMESTAMP; """ ALTER TABLE tags ADD COLUMN enabled INT NOT NULL DEFAULT 1; """, +""" +DROP VIEW most_recent_posts; +CREATE VIEW most_recent_posts AS + SELECT max(id), * FROM posts WHERE deleted = 0 GROUP BY thread; +""", ] diff --git a/apioforum/forum.py b/apioforum/forum.py index d13f1fe..79bb3ee 100644 --- a/apioforum/forum.py +++ b/apioforum/forum.py @@ -155,7 +155,8 @@ def view_forum(forum,page=1): most_recent_posts.content as mrp_content, most_recent_posts.deleted as mrp_deleted FROM threads - INNER JOIN most_recent_posts ON most_recent_posts.thread = threads.id + LEFT JOIN most_recent_posts ON + most_recent_posts.thread = threads.id AND most_recent_posts.deleted = 0 INNER JOIN number_of_posts ON number_of_posts.thread = threads.id LEFT OUTER JOIN thread_tags ON threads.id = thread_tags.thread WHERE threads.forum = ? {tagfilter_clause} diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html index ca48f21..825aaba 100644 --- a/apioforum/templates/view_forum.html +++ b/apioforum/templates/view_forum.html @@ -163,7 +163,7 @@ you do not have permission to create threads in this forum - {% if not thread.mrp_deleted %} + {% if thread.mrp_content %}
{{ disp_user(thread.mrp_author) }} @@ -176,8 +176,8 @@ you do not have permission to create threads in this forum {% else %} {% endif %} -- cgit v1.2.3