aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--apioforum/db.py5
-rw-r--r--apioforum/forum.py3
-rw-r--r--apioforum/templates/view_forum.html6
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
</a>
</div>
</div>
- {% if not thread.mrp_deleted %}
+ {% if thread.mrp_content %}
<div class="listing-caption preview-caption">
{{ disp_user(thread.mrp_author) }}
<span class="thread-preview-ts">
@@ -176,8 +176,8 @@ you do not have permission to create threads in this forum
{% else %}
<div class="listing-caption preview-caption">
<a class="thread-preview-post"
- href="{{post_jump(thread.mrp_id)}}">
- latest post
+ href="{{url_for('thread.view_thread',thread_id=thread.id)}}">
+ no posts
</a>
</div>
{% endif %}