Fix overdue detection ignoring due_time, harden SW precache installs

Task.is_overdue only compared due_date to today, so a task due at 9am
stayed "not overdue" until midnight regardless of due_time (Gitea #7).
Now factors in due_time when the due date is today, mirrored in the
offline app's isTaskOverdue().

Also hardened the service worker's install step: cache.addAll() lets
the browser's HTTP cache satisfy each precache fetch, and since static
assets here send no Cache-Control/ETag (just Last-Modified), a
CACHE_NAME bump wasn't reliably guaranteed to pick up fresh files.
Forcing {cache: 'reload'} on each precache fetch fixes that.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Keith Smith
2026-09-05 09:29:37 -06:00
co-authored by Claude Sonnet 5
parent c454423d4d
commit d67a7e4d8f
4 changed files with 78 additions and 8 deletions
+7 -4
View File
@@ -155,16 +155,19 @@ class Task(models.Model):
from django.utils import timezone
from zoneinfo import ZoneInfo
# Get current date in user's timezone
# Get current date/time in user's timezone
try:
user_tz = ZoneInfo(self.user.timezone)
user_now = timezone.now().astimezone(user_tz)
user_today = user_now.date()
except (Exception,):
# Fall back to UTC if user timezone is invalid or missing
user_today = timezone.now().date()
user_now = timezone.now()
return self.due_date < user_today
if self.due_date < user_now.date():
return True
if self.due_date == user_now.date() and self.due_time:
return self.due_time < user_now.time()
return False
return False
@property