WebUI supports frequency timegen
This commit is contained in:
parent
57b7586c0a
commit
facde97f80
2 changed files with 37 additions and 0 deletions
35
larigira/timeform_frequency.py
Normal file
35
larigira/timeform_frequency.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
from flask_wtf import Form
|
||||||
|
from wtforms import StringField, DateTimeField, IntegerField, validators, \
|
||||||
|
SubmitField
|
||||||
|
|
||||||
|
|
||||||
|
class FrequencyAlarmForm(Form):
|
||||||
|
nick = StringField(u'Alarm nick', validators=[validators.required()],
|
||||||
|
description='A simple name to recognize this alarm')
|
||||||
|
start = DateTimeField(u'Start date and time',
|
||||||
|
validators=[validators.required()],
|
||||||
|
description='Date before which no alarm will ring, '
|
||||||
|
'expressed as YYYY-MM-DD HH:MM:SS')
|
||||||
|
end = DateTimeField(u'End date and time',
|
||||||
|
validators=[validators.optional()],
|
||||||
|
description='Date after which no alarm will ring, '
|
||||||
|
'expressed as YYYY-MM-DD HH:MM:SS')
|
||||||
|
interval = IntegerField(u'Frequency',
|
||||||
|
validators=[validators.required()],
|
||||||
|
description='in seconds')
|
||||||
|
submit = SubmitField(u'Submit')
|
||||||
|
|
||||||
|
|
||||||
|
def frequencyalarm_receive(form):
|
||||||
|
obj = {
|
||||||
|
'kind': 'frequency',
|
||||||
|
'nick': form.nick.data,
|
||||||
|
'start': int(form.start.data.strftime('%s')),
|
||||||
|
'interval': form.interval.data,
|
||||||
|
}
|
||||||
|
if form.end.data:
|
||||||
|
obj['end'] = int(form.end.data.strftime('%s'))
|
||||||
|
return obj
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -67,9 +67,11 @@ setup(name='larigira',
|
||||||
],
|
],
|
||||||
'larigira.timeform_create': [
|
'larigira.timeform_create': [
|
||||||
'single = larigira.timeform_single:SingleAlarmForm',
|
'single = larigira.timeform_single:SingleAlarmForm',
|
||||||
|
'frequency = larigira.timeform_frequency:FrequencyAlarmForm',
|
||||||
],
|
],
|
||||||
'larigira.timeform_receive': [
|
'larigira.timeform_receive': [
|
||||||
'single = larigira.timeform_single:singlealarm_receive',
|
'single = larigira.timeform_single:singlealarm_receive',
|
||||||
|
'frequency = larigira.timeform_frequency:frequencyalarm_receive',
|
||||||
],
|
],
|
||||||
'larigira.audioform_create': [
|
'larigira.audioform_create': [
|
||||||
'static = larigira.audioform_static:StaticAudioForm',
|
'static = larigira.audioform_static:StaticAudioForm',
|
||||||
|
|
Loading…
Reference in a new issue