avoid 500 when end=null in frequency timespec

This commit is contained in:
boyska 2021-03-02 23:43:11 +01:00
parent 3619d2c7a6
commit 1adfa83d1d
2 changed files with 5 additions and 5 deletions

View file

@ -1,13 +1,13 @@
import logging
from datetime import datetime
from flask_wtf import Form
from pytimeparse.timeparse import timeparse
from flask_wtf import Form
from larigira.formutils import EasyDateTimeField
from wtforms import (SelectMultipleField, StringField, SubmitField,
ValidationError, validators)
from larigira.formutils import EasyDateTimeField
log = logging.getLogger(__name__)
@ -84,9 +84,9 @@ class FrequencyAlarmForm(Form):
def populate_from_timespec(self, timespec):
if "nick" in timespec:
self.nick.data = timespec["nick"]
if "start" in timespec:
if timespec.get("start"):
self.start.data = datetime.fromtimestamp(timespec["start"])
if "end" in timespec:
if timespec.get("end"):
self.end.data = datetime.fromtimestamp(timespec["end"])
if "weekdays" in timespec:
self.weekdays.data = timespec["weekdays"]