Fix crash on no database

This commit is contained in:
Michel Roux 2019-12-13 19:21:08 +01:00
parent 896927e156
commit 1d06a9507c
2 changed files with 5 additions and 4 deletions

6
app.py
View File

@ -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):

View File

@ -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()])