From 7bef642f4e6ddf5c12c29848c47396daab2ee5ee Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Thu, 8 Feb 2018 21:12:54 +0100 Subject: [PATCH] Don't submit reports for already banned torrents (#448) If users kept their page open for a while before reporting a torrent, and mods got it in the meantime, users could still submit reports for that torrent. This is silly and really doesn't need to happen. --- nyaa/views/torrents.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nyaa/views/torrents.py b/nyaa/views/torrents.py index 8bd4e1e..8fa1b69 100644 --- a/nyaa/views/torrents.py +++ b/nyaa/views/torrents.py @@ -400,6 +400,12 @@ def submit_report(torrent_id): flask.abort(403) form = forms.ReportForm(flask.request.form) + torrent = models.Torrent.by_id(torrent_id) + if not torrent: + flask.abort(404) + if torrent.banned: + flask.flash("The torrent you've tried to report is already banned.", 'danger') + flask.abort(404) if flask.request.method == 'POST' and form.validate(): report_reason = form.reason.data