From 07a69f24fb0ddabc55398b4853dcf642429ce593 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 29 Sep 2020 13:35:19 +0200 Subject: [PATCH] Fix reset order on delete --- pynyaata/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index 79aa820..2fc121d 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -121,11 +121,6 @@ def remove_garbage(link): @mysql_required @auth.login_required def admin(): - folders = AnimeFolder.query.all() - for folder in folders: - for title in folder.titles: - title.links.sort(key=attrgetter('season')) - folder.titles.sort(key=attrgetter('name')) form = DeleteForm(request.form) if form.validate_on_submit(): @@ -138,6 +133,12 @@ def admin(): else: form._errors = {'id': ['Id %s was not found in the database' % form.id.data]} + folders = AnimeFolder.query.all() + for folder in folders: + for title in folder.titles: + title.links.sort(key=attrgetter('season')) + folder.titles.sort(key=attrgetter('name')) + return render_template('admin/list.html', search_form=SearchForm(), folders=folders, action_form=form)