diff --git a/larigira/audioform_script.py b/larigira/audioform_script.py index d6e5782..fa06101 100644 --- a/larigira/audioform_script.py +++ b/larigira/audioform_script.py @@ -1,12 +1,15 @@ from flask_wtf import Form from wtforms import StringField, validators, SubmitField, ValidationError +from larigira.formutils import AutocompleteStringField class ScriptAudioForm(Form): nick = StringField('Audio nick', validators=[validators.required()], description='A simple name to recognize this audio') - name = StringField('Name', validators=[validators.required()], - description='filename (NOT path) of the script') + name = AutocompleteStringField( + 'dl-suggested-scripts', + 'Name', validators=[validators.required()], + description='filename (NOT path) of the script') args = StringField('Arguments', description='arguments, separated by ";"') submit = SubmitField('Submit') diff --git a/larigira/dbadmin/__init__.py b/larigira/dbadmin/__init__.py index 46de389..60833d7 100644 --- a/larigira/dbadmin/__init__.py +++ b/larigira/dbadmin/__init__.py @@ -56,6 +56,13 @@ def get_suggested_dirs(): return list(dirset) +def get_suggested_scripts(): + base = get_conf()['SCRIPTS_PATH'] + fnames = [f for f in os.listdir(base) + if os.access(os.path.join(base, f), os.R_OK | os.X_OK)] + return fnames + + def get_suggestions(): files = get_suggested_files() if len(files) > 200: @@ -63,7 +70,9 @@ def get_suggestions(): files = files[:200] return dict( files=files, - dirs=get_suggested_dirs()) + dirs=get_suggested_dirs(), + scripts=get_suggested_scripts(), + ) @db.route('/')