Skip to content
This repository has been archived by the owner on Nov 26, 2018. It is now read-only.

Commit

Permalink
Handle invalid dates gracefully.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb committed Jul 6, 2015
1 parent 487c870 commit 741b49a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions botbot/apps/logs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,13 @@ def set_view_date(self):
"""Determine start date for queryset"""
if all([field in self.kwargs for field in ['year', 'month', 'day']]):
# localize date so logs start at local time
return datetime.datetime(year=int(self.kwargs['year']),
month=int(self.kwargs['month']),
day=int(self.kwargs['day']),
tzinfo=self.request_timezone)
try:
return datetime.datetime(year=int(self.kwargs['year']),
month=int(self.kwargs['month']),
day=int(self.kwargs['day']),
tzinfo=self.request_timezone)
except ValueError:
raise Http404("Invalid date.")

# Use the last page.
self.kwargs['page'] = 'last'
Expand Down

0 comments on commit 741b49a

Please sign in to comment.