parent
1e902a069d
commit
0a1f78ebb5
1 changed files with 14 additions and 9 deletions
|
@ -9,18 +9,20 @@ from wtforms import StringField, DateTimeField, validators, \
|
||||||
class FrequencyAlarmForm(Form):
|
class FrequencyAlarmForm(Form):
|
||||||
nick = StringField('Alarm nick', validators=[validators.required()],
|
nick = StringField('Alarm nick', validators=[validators.required()],
|
||||||
description='A simple name to recognize this alarm')
|
description='A simple name to recognize this alarm')
|
||||||
start = DateTimeField('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('End date and time',
|
|
||||||
validators=[validators.optional()],
|
|
||||||
description='Date after which no alarm will ring, '
|
|
||||||
'expressed as YYYY-MM-DD HH:MM:SS')
|
|
||||||
interval = StringField('Frequency',
|
interval = StringField('Frequency',
|
||||||
validators=[validators.required()],
|
validators=[validators.required()],
|
||||||
description='in seconds, or human-readable '
|
description='in seconds, or human-readable '
|
||||||
'(like 9w3d12h)')
|
'(like 9w3d12h)')
|
||||||
|
start = DateTimeField('Start date and time',
|
||||||
|
validators=[validators.optional()],
|
||||||
|
description='Date before which no alarm will ring, '
|
||||||
|
'expressed as YYYY-MM-DD HH:MM:SS; if omitted, the '
|
||||||
|
'alarm will always ring')
|
||||||
|
end = DateTimeField('End date and time',
|
||||||
|
validators=[validators.optional()],
|
||||||
|
description='Date after which no alarm will ring, '
|
||||||
|
'expressed as YYYY-MM-DD HH:MM:SS; if omitted, the '
|
||||||
|
'alarm will always ring')
|
||||||
submit = SubmitField('Submit')
|
submit = SubmitField('Submit')
|
||||||
|
|
||||||
def populate_from_timespec(self, timespec):
|
def populate_from_timespec(self, timespec):
|
||||||
|
@ -46,9 +48,12 @@ def frequencyalarm_receive(form):
|
||||||
obj = {
|
obj = {
|
||||||
'kind': 'frequency',
|
'kind': 'frequency',
|
||||||
'nick': form.nick.data,
|
'nick': form.nick.data,
|
||||||
'start': int(form.start.data.strftime('%s')),
|
|
||||||
'interval': form.interval.data,
|
'interval': form.interval.data,
|
||||||
}
|
}
|
||||||
|
if form.start.data:
|
||||||
|
obj['start'] = int(form.end.data.strftime('%s'))
|
||||||
|
else:
|
||||||
|
obj['start'] = 0
|
||||||
if form.end.data:
|
if form.end.data:
|
||||||
obj['end'] = int(form.end.data.strftime('%s'))
|
obj['end'] = int(form.end.data.strftime('%s'))
|
||||||
return obj
|
return obj
|
||||||
|
|
Loading…
Reference in a new issue