1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 15:40:00 +00:00

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

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)