add WebUI for randomdir audiogen

fix #25
This commit is contained in:
boyska 2016-09-15 09:44:44 +02:00
parent 6135ddc144
commit 556783c2ab
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
2 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,34 @@
import flask_wtf
from wtforms import StringField, validators, SubmitField, IntegerField
class Form(flask_wtf.Form):
nick = StringField('Audio nick', validators=[validators.required()],
description='A simple name to recognize this audio')
path = StringField('Path', validators=[validators.required()],
description='Full path to source directory')
howmany = IntegerField('Number', validators=[validators.optional()],
default=1,
description='How many songs to be picked'
'from this dir; defaults to 1')
submit = SubmitField('Submit')
def populate_from_audiospec(self, audiospec):
if 'nick' in audiospec:
self.nick.data = audiospec['nick']
if 'paths' in audiospec:
self.path.data = audiospec['paths'][0]
if 'howmany' in audiospec:
self.howmany.data = audiospec['howmany']
else:
self.howmany.data = 1
def receive(form):
return {
'kind': 'randomdir',
'nick': form.nick.data,
'paths': [form.path.data],
'howmany': form.howmany.data or 1
}

View file

@ -77,10 +77,12 @@ setup(name='larigira',
'larigira.audioform_create': [
'static = larigira.audioform_static:StaticAudioForm',
'script = larigira.audioform_script:ScriptAudioForm',
'randomdir = larigira.audioform_randomdir:Form',
],
'larigira.audioform_receive': [
'static = larigira.audioform_static:staticaudio_receive',
'script = larigira.audioform_script:scriptaudio_receive',
'randomdir = larigira.audioform_randomdir:receive',
],
},
classifiers=[