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.
This commit is contained in:
Nicolas F 2018-02-08 21:12:54 +01:00 committed by Arylide
parent 658eefe42a
commit 7bef642f4e
1 changed files with 6 additions and 0 deletions

View File

@ -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