Internal
Public Access
Only proactive notification was the once-a-day 6-7AM digest. Wires up the previously-unused User.default_reminder_minutes profile setting and ScheduledReminder model (Gitea #8) to send timely per-task alerts: - Task.reschedule_reminders(), hooked into Task.save() via a dirty-check against due_date/due_time/reminder_at/status/is_deleted, (re)creates up to 3 ScheduledReminder rows per active due task: a "before due" reminder (from reminder_at if set, else default_reminder_minutes before due), a "due now" notification, and an "overdue" notification (mirroring is_overdue's day-after rule for date-only due tasks). Hooking into save() means every call site - web views, the API, and sync - picks this up automatically. - New Celery task send_scheduled_reminders (beat schedule: every 5 min) sends due reminders via whichever of email/push the user has enabled, reusing the existing per-user channel toggles, and logs them to the Notification table. - 14 new tests covering the scheduling math, due-date-change/completion/ deletion cleanup, and the sending task's channel and timing behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
29 lines
883 B
Python
29 lines
883 B
Python
"""
|
|
Notification admin configuration.
|
|
"""
|
|
|
|
from django.contrib import admin
|
|
from .models import Notification, ScheduledReminder
|
|
|
|
|
|
@admin.register(Notification)
|
|
class NotificationAdmin(admin.ModelAdmin):
|
|
"""Admin for Notification."""
|
|
|
|
list_display = ['title', 'user', 'notification_type', 'is_read', 'created_at']
|
|
list_filter = ['notification_type', 'is_read', 'created_at']
|
|
search_fields = ['title', 'message', 'user__email']
|
|
ordering = ['-created_at']
|
|
raw_id_fields = ['user', 'task']
|
|
|
|
|
|
@admin.register(ScheduledReminder)
|
|
class ScheduledReminderAdmin(admin.ModelAdmin):
|
|
"""Admin for ScheduledReminder."""
|
|
|
|
list_display = ['task', 'reminder_type', 'remind_at', 'is_sent', 'sent_at', 'created_at']
|
|
list_filter = ['reminder_type', 'is_sent', 'remind_at']
|
|
search_fields = ['task__title']
|
|
ordering = ['remind_at']
|
|
raw_id_fields = ['task']
|