search: Add links for comments
This commit is contained in:
parent
8960ca22cd
commit
a039d1b500
|
@ -6,7 +6,7 @@ from app.routes.admin import index, groups, account, forums, \
|
|||
attachments, config, members, polls, login_as
|
||||
from app.routes.forum import index, topic
|
||||
from app.routes.polls import vote, delete
|
||||
from app.routes.posts import edit
|
||||
from app.routes.posts import edit, redirect
|
||||
from app.routes.programs import index, submit, program
|
||||
from app.routes.api import markdown
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
from app import app, db
|
||||
from app.models.attachment import Attachment
|
||||
from app.models.comment import Comment
|
||||
from app.models.forum import Forum
|
||||
from app.models.post import Post
|
||||
from app.models.program import Program
|
||||
from app.models.thread import Thread
|
||||
from app.models.topic import Topic
|
||||
from app.models.user import Member
|
||||
from app.utils.render import render
|
||||
from app.utils.check_csrf import check_csrf
|
||||
from app.utils.priv_required import priv_required
|
||||
from app.forms.forum import CommentEditForm, AnonymousCommentEditForm, TopicEditForm
|
||||
from app.forms.post import MovePost, SearchThread
|
||||
from wtforms import BooleanField
|
||||
from urllib.parse import urlparse
|
||||
from flask import redirect, url_for, abort, request, flash
|
||||
from flask_login import login_required, current_user
|
||||
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()
|
||||
|
||||
owner = c.thread.owner_post
|
||||
|
||||
if hasattr(owner, 'forum'):
|
||||
# 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))
|
||||
else:
|
||||
# Is a program
|
||||
url = url_for('program_view', page=owner.name)
|
||||
|
||||
return redirect(url, 301)
|
|
@ -36,9 +36,11 @@
|
|||
'sortBy': request.args.get('sortBy')}) }}
|
||||
{% for i in results.items %}
|
||||
<div>
|
||||
{{ i.id }} {{ i.title }} {{ i.forum }}<br>
|
||||
{{ i.id }} {{ i.title }}<br>
|
||||
{% if i.forum %}
|
||||
<a href="{{ url_for('forum_topic', f=i.forum, page=(i , 'fin')) }}">{{ i.title }}</a>
|
||||
{% elif i.thread %}
|
||||
<a href="{{ url_for('redirect_post', postid=i.id) }}">{{ i.thread.owner_topic[0].title }}</a>
|
||||
{% endif %}
|
||||
{{ i.headline }}<br>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue