move the choices for AI models in SelectField to be delayed to when SettingsForm is created to avoid gunicorn barfing on init -- its all circular import issues I think, but this is bearable for now
This commit is contained in:
@@ -9,6 +9,7 @@ from main import db, app, ma
|
|||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
|
|
||||||
|
#### FIXME/KLUDGE (this is here to avoid circular import):
|
||||||
################################################################################
|
################################################################################
|
||||||
# Class describing AI_MODEL in the database, and via sqlalchemy, connected to the DB as well
|
# Class describing AI_MODEL in the database, and via sqlalchemy, connected to the DB as well
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -57,8 +58,8 @@ class SettingsForm(FlaskForm):
|
|||||||
recycle_bin_path = StringField('Path to temporarily store deleted images in:', [validators.DataRequired()])
|
recycle_bin_path = StringField('Path to temporarily store deleted images in:', [validators.DataRequired()])
|
||||||
metadata_path = StringField('Path to store metadata to:', [validators.DataRequired()])
|
metadata_path = StringField('Path to store metadata to:', [validators.DataRequired()])
|
||||||
auto_rotate = BooleanField('Automatically rotate jpegs based on exif', [validators.AnyOf([True, False])])
|
auto_rotate = BooleanField('Automatically rotate jpegs based on exif', [validators.AnyOf([True, False])])
|
||||||
default_refimg_model = SelectField( 'Default model to use for reference images', choices=[(c.id, c.name) for c in AIModel.query.order_by('id')] )
|
default_refimg_model = SelectField( 'Default model to use for reference images' )
|
||||||
default_scan_model = SelectField( 'Default model to use for all scanned images', choices=[(c.id, c.name) for c in AIModel.query.order_by('id')] )
|
default_scan_model = SelectField( 'Default model to use for all scanned images' )
|
||||||
default_threshold = StringField('Face Distance threshold (below is a match):', [validators.DataRequired()])
|
default_threshold = StringField('Face Distance threshold (below is a match):', [validators.DataRequired()])
|
||||||
face_size_limit = StringField('Minimum size of a face:', [validators.DataRequired()])
|
face_size_limit = StringField('Minimum size of a face:', [validators.DataRequired()])
|
||||||
scheduled_import_scan = IntegerField('Days between forced scan of import path', [validators.DataRequired()])
|
scheduled_import_scan = IntegerField('Days between forced scan of import path', [validators.DataRequired()])
|
||||||
@@ -75,6 +76,8 @@ class SettingsForm(FlaskForm):
|
|||||||
@login_required
|
@login_required
|
||||||
def settings():
|
def settings():
|
||||||
form = SettingsForm(request.form)
|
form = SettingsForm(request.form)
|
||||||
|
form.default_refimg_model.choices=[(c.id, c.name) for c in AIModel.query.order_by('id')]
|
||||||
|
form.default_scan_model.choices=[(c.id, c.name) for c in AIModel.query.order_by('id')]
|
||||||
page_title='Settings'
|
page_title='Settings'
|
||||||
HELP={}
|
HELP={}
|
||||||
HELP['base_path']="Optional: if the paths below are absolute, then this field is ignored. If they are relative, then this field is prepended"
|
HELP['base_path']="Optional: if the paths below are absolute, then this field is ignored. If they are relative, then this field is prepended"
|
||||||
@@ -123,6 +126,8 @@ def settings():
|
|||||||
return render_template("settings.html", form=form, page_title=page_title, HELP=HELP)
|
return render_template("settings.html", form=form, page_title=page_title, HELP=HELP)
|
||||||
else:
|
else:
|
||||||
form = SettingsForm( obj=Settings.query.first() )
|
form = SettingsForm( obj=Settings.query.first() )
|
||||||
|
form.default_refimg_model.choices=[(c.id, c.name) for c in AIModel.query.order_by('id')]
|
||||||
|
form.default_scan_model.choices=[(c.id, c.name) for c in AIModel.query.order_by('id')]
|
||||||
return render_template("settings.html", form=form, page_title = page_title, HELP=HELP)
|
return render_template("settings.html", form=form, page_title = page_title, HELP=HELP)
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user