From 4eed4971a3b467e50005138f7c7232b4be862ea6 Mon Sep 17 00:00:00 2001 From: Anna-Maria Meriniemi Date: Sat, 26 Aug 2017 02:52:59 +0300 Subject: [PATCH] Fix banning torrents without uploader ip Pretty much just for archived torrents --- nyaa/views/torrents.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nyaa/views/torrents.py b/nyaa/views/torrents.py index 65f92f1..2a55ff2 100644 --- a/nyaa/views/torrents.py +++ b/nyaa/views/torrents.py @@ -157,11 +157,16 @@ def edit_torrent(torrent_id): ipbanned = None if editor.is_moderator: - tbanned = models.Ban.banned(None, torrent.uploader_ip).first() - ubanned = True + torrent_ip_banned = True + user_ip_banned = True + + # Archived torrents do not have a null uploader_ip + if torrent.uploader_ip: + torrent_ip_banned = models.Ban.banned(None, torrent.uploader_ip).first() + if torrent.user: - ubanned = models.Ban.banned(None, torrent.user.last_login_ip).first() - ipbanned = (tbanned and ubanned) + user_ip_banned = models.Ban.banned(None, torrent.user.last_login_ip).first() + ipbanned = (torrent_ip_banned and user_ip_banned) return flask.render_template('edit.html', form=form,