diff --git a/app/routes/posts/redirect.py b/app/routes/posts/redirect.py
index 81c6fa7..f622ce5 100644
--- a/app/routes/posts/redirect.py
+++ b/app/routes/posts/redirect.py
@@ -1,6 +1,7 @@
from app import app
from app.models.comment import Comment
from app.models.thread import Thread
+from app.models.program import Program
from flask import redirect, url_for
@@ -10,17 +11,19 @@ def redirect_post(postid):
owner = c.thread.owner_post
+ # Get the comments for the thread
+ comments = Comment.query.where(
+ Comment.thread_id == c.thread.id,
+ Comment.date_created <= c.date_created
+ ).order_by(
+ Comment.date_created.asc()
+ ).paginate(per_page=Thread.COMMENTS_PER_PAGE, error_out=False)
+
if owner.type == 'topic':
# Is a topic
- comments = Comment.query.where(
- Comment.thread_id == c.thread.id,
- Comment.date_created <= c.date_created
- ).order_by(
- Comment.date_created.asc()
- ).paginate(per_page=Thread.COMMENTS_PER_PAGE, error_out=False)
url = url_for('forum_topic', f=owner.forum, page=(owner, comments.pages), _anchor=str(c.id))
else:
# Is a program
- url = url_for('program_view', page=owner.name)
+ url = url_for('program_view', page=(owner, comments.pages), _anchor=str(c.id))
return redirect(url, 301)
diff --git a/app/templates/search.html b/app/templates/search.html
index 9d037e4..01c87d5 100644
--- a/app/templates/search.html
+++ b/app/templates/search.html
@@ -54,7 +54,13 @@
{% if i.forum %}
{{ i.title }}
{% elif i.thread %}
- {% if i.thread.owner_topic %}
+ {% if i.thread.owner_program %}
+ {% if i.thread.owner_program[0].id == i.id %}
+ {{ i.thread.owner_program[0].name }}
+ {% else %}
+ {{ i.thread.owner_program[0].name }}
+ {% endif %}
+ {% elif i.thread.owner_topic %}
{{ i.thread.owner_topic[0].title }}
{% endif %}
{% endif %}