From 1d06a9507cdf7216e3959ee088d78b2c281e2782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=A9fir=20Destiny?= Date: Fri, 13 Dec 2019 19:21:08 +0100 Subject: [PATCH] Fix crash on no database --- app.py | 6 ++++-- models.py | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index ce5b9ae..10ae463 100644 --- a/app.py +++ b/app.py @@ -126,15 +126,17 @@ def admin_delete(): def admin_edit(link_id): link = AnimeLink.query.filter_by(id=link_id).first() titles = AnimeTitle.query.all() + edit_form = EditForm() + edit_form.folder.choices = [(query.id, query.name) for query in AnimeFolder.query.all()] - return render_template('admin/edit.html', search_form=SearchForm(), link=link, titles=titles, edit_form=EditForm()) + return render_template('admin/edit.html', search_form=SearchForm(), link=link, titles=titles, edit_form=edit_form) @app.route('/admin/add') @auth.login_required def admin_add(): edit_form = EditForm() - edit_form.folder.choices = [(0, '')] + edit_form.folder.choices + edit_form.folder.choices = [(0, '')] + [(query.id, query.name) for query in AnimeFolder.query.all()] titles = AnimeTitle.query.all() link = AnimeLink() for attr in dir(link): diff --git a/models.py b/models.py index 28312ff..594de94 100644 --- a/models.py +++ b/models.py @@ -42,8 +42,7 @@ class DeleteForm(FlaskForm): class EditForm(FlaskForm): id = HiddenField('id') - folder = SelectField('folder', validators=[DataRequired()], - choices=[(query.id, query.name) for query in AnimeFolder.query.all()], coerce=int) + folder = SelectField('folder', validators=[DataRequired()], coerce=int) name = StringField('name', validators=[DataRequired()]) link = URLField('link', validators=[DataRequired()]) season = StringField('season', validators=[DataRequired()])