parent
6135ddc144
commit
556783c2ab
2 changed files with 36 additions and 0 deletions
34
larigira/audioform_randomdir.py
Normal file
34
larigira/audioform_randomdir.py
Normal 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
|
||||
}
|
||||
|
2
setup.py
2
setup.py
|
@ -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=[
|
||||
|
|
Loading…
Reference in a new issue