From bb30f6e3d2d223b61e408b2c9cd49f5a101520a7 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Thu, 25 May 2017 21:11:55 +0300 Subject: [PATCH] Scroll user to their new comment after submission --- nyaa/routes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nyaa/routes.py b/nyaa/routes.py index f2398d5..ebe5a9c 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -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)