feat: pwa notifications

This commit is contained in:
2026-07-14 20:49:30 +02:00
parent 2cf7b283e0
commit 5198826f83
21 changed files with 1563 additions and 8 deletions
+30
View File
@@ -41,6 +41,12 @@ class ScheduledDose(models.Model):
amount = models.CharField(
max_length=20, default="1/4", help_text='Free text, e.g. "1/4", "1", "5 mg".'
)
reminder_time = models.TimeField(
null=True,
blank=True,
help_text="Send a push reminder at this time if the dose isn't ticked off. "
"Leave empty for no reminder.",
)
is_active = models.BooleanField(default=True)
class Meta:
@@ -92,6 +98,30 @@ class DoseLog(models.Model):
return super().save(*args, **kwargs)
class ReminderSent(models.Model):
"""One row per dose per day once its reminder has gone out.
This is what stops a reminder being re-sent every time the cron job ticks.
"""
scheduled_dose = models.ForeignKey(
ScheduledDose, on_delete=models.CASCADE, related_name="reminders"
)
date = models.DateField()
sent_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ["-sent_at"]
constraints = [
models.UniqueConstraint(
fields=["scheduled_dose", "date"], name="unique_reminder_per_day"
)
]
def __str__(self):
return f"{self.date}{self.scheduled_dose}"
class PulseReading(models.Model):
"""One heart-rate measurement per day, in beats per minute."""