diff --git a/larigira/timeform_frequency.py b/larigira/timeform_frequency.py index 85efbf3..f0d09fd 100644 --- a/larigira/timeform_frequency.py +++ b/larigira/timeform_frequency.py @@ -9,18 +9,20 @@ from wtforms import StringField, DateTimeField, validators, \ class FrequencyAlarmForm(Form): nick = StringField('Alarm nick', validators=[validators.required()], 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', validators=[validators.required()], description='in seconds, or human-readable ' '(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') def populate_from_timespec(self, timespec): @@ -46,9 +48,12 @@ def frequencyalarm_receive(form): obj = { 'kind': 'frequency', 'nick': form.nick.data, - 'start': int(form.start.data.strftime('%s')), 'interval': form.interval.data, } + if form.start.data: + obj['start'] = int(form.end.data.strftime('%s')) + else: + obj['start'] = 0 if form.end.data: obj['end'] = int(form.end.data.strftime('%s')) return obj