summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2020-02-23 20:20:35 +1100
committerYingtong Li <runassudo@yingtongli.me>2020-02-23 20:35:03 +1100
commite69efdc816ec4a008b3f495c8ec3b30b4509e97c (patch)
tree36e686f1d41f50ab60d397ed560130da5912b1c2
parent28eb72ef81de70919cc9d338fed0281affa7b70d (diff)
Fix error when dates invalid
-rw-r--r--sstreasury/views.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/sstreasury/views.py b/sstreasury/views.py
index 4acf8a8..87d5903 100644
--- a/sstreasury/views.py
+++ b/sstreasury/views.py
@@ -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
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.