From 73c84ce5ec89235ba1507b20abadb8b989f3a5d1 Mon Sep 17 00:00:00 2001 From: nyaazi Date: Sat, 20 May 2017 13:58:58 +0300 Subject: [PATCH] Remove duplicate reports for already reviewed torrent --- nyaa/models.py | 4 ++++ nyaa/routes.py | 1 + nyaa/templates/view.html | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nyaa/models.py b/nyaa/models.py index e098ffa..1ff6925 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -429,6 +429,10 @@ class Report(db.Model): # reports = cls.query.filter_by(status=0).paginate(page=page, per_page=20) return reports + @classmethod + def remove_reviewed(cls, id): + return cls.query.filter(cls.torrent_id == id, cls.status == 0).delete() + # class Session(db.Model): # __tablename__ = 'sessions' # diff --git a/nyaa/routes.py b/nyaa/routes.py index 401b639..d12c002 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -710,6 +710,7 @@ def view_reports(): else: report.status = 2 + models.Report.remove_reviewed(data['torrent']) db.session.commit() flask.flash('Closed report #{}'.format(report.id), 'success') return flask.redirect(flask.url_for('view_reports')) diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index ca778a4..1c8311e 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -62,7 +62,7 @@ soon{% endif %} -