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']:
|
||||
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:
|
||||
errors.append('Due date is not a valid date')
|
||||
revision.date = form['date']
|
||||
revision.date = None
|
||||
else:
|
||||
errors.append('A due date must be specified')
|
||||
|
||||
if form['event_dt']:
|
||||
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:
|
||||
errors.append('Event date/time is not a valid date-time')
|
||||
revision.event_dt = form['event_dt']
|
||||
revision.event_dt = None
|
||||
else:
|
||||
revision.event_dt = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user