search: Fix links for comments
This commit is contained in:
parent
e8ce99c194
commit
61c4c0392e
|
@ -21,17 +21,20 @@ from sqlalchemy import text
|
|||
|
||||
@app.route('/post/<int:postid>', methods=['GET', 'POST'])
|
||||
def redirect_post(postid):
|
||||
print(postid)
|
||||
c = Comment.query.filter_by(id=postid).first_or_404()
|
||||
c = Comment.query.get_or_404(postid)
|
||||
|
||||
owner = c.thread.owner_post
|
||||
|
||||
if hasattr(owner, 'forum'):
|
||||
if owner.type == 'topic':
|
||||
# Is a topic
|
||||
comments = owner.thread.comments.order_by(Comment.date_created.asc()).where(
|
||||
Comment.date_created >= c.date_created
|
||||
).paginate(0, Thread.COMMENTS_PER_PAGE, True)
|
||||
url = url_for('forum_topic', f=owner.forum, page=(owner, comments.pages))
|
||||
print('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)
|
||||
|
|
Loading…
Reference in New Issue