Fix error when dates invalid
This commit is contained in:
parent
28eb72ef81
commit
e69efdc816
@ -110,19 +110,21 @@ def revision_from_form(budget, revision, form):
|
|||||||
|
|
||||||
if form['date']:
|
if form['date']:
|
||||||
try:
|
try:
|
||||||
form_date = datetime.strptime(form['date'], '%Y-%m-%d')
|
form_date = timezone.make_aware(datetime.strptime(form['date'], '%Y-%m-%d'))
|
||||||
|
revision.date = form_date
|
||||||
except ValueError:
|
except ValueError:
|
||||||
errors.append('Due date is not a valid date')
|
errors.append('Due date is not a valid date')
|
||||||
revision.date = form['date']
|
revision.date = None
|
||||||
else:
|
else:
|
||||||
errors.append('A due date must be specified')
|
errors.append('A due date must be specified')
|
||||||
|
|
||||||
if form['event_dt']:
|
if form['event_dt']:
|
||||||
try:
|
try:
|
||||||
form_event_dt = datetime.strptime(form['event_dt'], '%Y-%m-%d %H:%M')
|
form_event_dt = timezone.make_aware(datetime.strptime(form['event_dt'], '%Y-%m-%d %H:%M'))
|
||||||
|
revision.event_dt = form_event_dt
|
||||||
except ValueError:
|
except ValueError:
|
||||||
errors.append('Event date/time is not a valid date-time')
|
errors.append('Event date/time is not a valid date-time')
|
||||||
revision.event_dt = form['event_dt']
|
revision.event_dt = None
|
||||||
else:
|
else:
|
||||||
revision.event_dt = None
|
revision.event_dt = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user