Scroll user to their new comment after submission

This commit is contained in:
TheAMM 2017-05-25 21:11:55 +03:00
parent 1ab3d6e3eb
commit bb30f6e3d2
1 changed files with 3 additions and 1 deletions

View File

@ -655,9 +655,11 @@ def view_torrent(torrent_id):
db.session.add(comment)
db.session.commit()
torrent_count = models.Comment.query.filter_by(torrent_id=torrent.id).count()
flask.flash('Comment successfully posted.', 'success')
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent_id))
return flask.redirect(flask.url_for('view_torrent', torrent_id=torrent_id, _anchor='com-'+str(torrent_count)))
# Only allow owners and admins to edit torrents
can_edit = flask.g.user and (flask.g.user is torrent.user or flask.g.user.is_moderator)