Internal
Public Access
Add error handling for timezone conversion
Fixes 500 error when user timezone is invalid or missing. Now gracefully falls back to UTC if timezone conversion fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
f2ca07d05d
commit
8d5faa8a6e
@@ -156,9 +156,13 @@ class Task(models.Model):
|
|||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
# Get current date in user's timezone
|
# Get current date in user's timezone
|
||||||
|
try:
|
||||||
user_tz = pytz.timezone(self.user.timezone)
|
user_tz = pytz.timezone(self.user.timezone)
|
||||||
user_now = timezone.now().astimezone(user_tz)
|
user_now = timezone.now().astimezone(user_tz)
|
||||||
user_today = user_now.date()
|
user_today = user_now.date()
|
||||||
|
except (pytz.UnknownTimeZoneError, AttributeError):
|
||||||
|
# Fall back to UTC if user timezone is invalid or missing
|
||||||
|
user_today = timezone.now().date()
|
||||||
|
|
||||||
return self.due_date < user_today
|
return self.due_date < user_today
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -220,9 +220,13 @@ class DashboardView(View):
|
|||||||
|
|
||||||
# Get today's date in user's timezone
|
# Get today's date in user's timezone
|
||||||
import pytz
|
import pytz
|
||||||
|
try:
|
||||||
user_tz = pytz.timezone(request.user.timezone)
|
user_tz = pytz.timezone(request.user.timezone)
|
||||||
user_now = timezone.now().astimezone(user_tz)
|
user_now = timezone.now().astimezone(user_tz)
|
||||||
today = user_now.date()
|
today = user_now.date()
|
||||||
|
except (pytz.UnknownTimeZoneError, AttributeError):
|
||||||
|
# Fall back to UTC if user timezone is invalid or missing
|
||||||
|
today = timezone.now().date()
|
||||||
|
|
||||||
# Get filter parameters
|
# Get filter parameters
|
||||||
current_filter = request.GET.get('filter', 'all')
|
current_filter = request.GET.get('filter', 'all')
|
||||||
|
|||||||
Reference in New Issue
Block a user