Fix crash on no database
This commit is contained in:
parent
896927e156
commit
1d06a9507c
6
app.py
6
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):
|
||||
|
@ -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()])
|
||||
|
Reference in New Issue
Block a user