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

Merge pull request #284 from sharkykh/fix-torrent-deletion-log

Fix torrent deletion log
This commit is contained in:
mreweilk 2017-07-05 12:10:03 -05:00 committed by GitHub
commit 580471dca9

View file

@ -732,11 +732,11 @@ def edit_torrent(torrent_id):
flask.abort(404) flask.abort(404)
# Only allow admins edit deleted torrents # Only allow admins edit deleted torrents
if torrent.deleted and not (flask.g.user and flask.g.user.is_moderator): if torrent.deleted and not (editor and editor.is_moderator):
flask.abort(404) flask.abort(404)
# Only allow torrent owners or admins edit torrents # Only allow torrent owners or admins edit torrents
if not flask.g.user or not (flask.g.user is torrent.user or flask.g.user.is_moderator): if not editor or not (editor is torrent.user or editor.is_moderator):
flask.abort(403) flask.abort(403)
if flask.request.method == 'POST' and form.validate(): if flask.request.method == 'POST' and form.validate():
@ -752,18 +752,18 @@ def edit_torrent(torrent_id):
torrent.complete = form.is_complete.data torrent.complete = form.is_complete.data
torrent.anonymous = form.is_anonymous.data torrent.anonymous = form.is_anonymous.data
if flask.g.user.is_trusted: if editor.is_trusted:
torrent.trusted = form.is_trusted.data torrent.trusted = form.is_trusted.data
if flask.g.user.is_moderator:
deleted_changed = torrent.deleted != form.is_deleted.data
if editor.is_moderator:
torrent.deleted = form.is_deleted.data torrent.deleted = form.is_deleted.data
if flask.g.user.is_moderator:
log = "Torrent [#{}]({}) marked as ".format(torrent.id, url)
url = flask.url_for('view_torrent', torrent_id=torrent.id) url = flask.url_for('view_torrent', torrent_id=torrent.id)
adminlog = models.AdminLog(log=(log+"deleted" if deleted_changed and editor.is_moderator:
if torrent.deleted else log = "Torrent [#{0}]({1}) marked as {2}".format(
log+"undeleted"), torrent.id, url, "deleted" if torrent.deleted else "undeleted")
admin_id=flask.g.user.id) adminlog = models.AdminLog(log=log, admin_id=editor.id)
db.session.add(adminlog) db.session.add(adminlog)
db.session.commit() db.session.commit()