From d3d5ac19f94cf7c811891b025c08390fa5671314 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 4 Jan 2021 07:39:29 +0100 Subject: [PATCH] Create models for medication tracker --- meds/models.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/meds/models.py b/meds/models.py index 71a8362..759677e 100644 --- a/meds/models.py +++ b/meds/models.py @@ -1,3 +1,37 @@ from django.db import models +from django.contrib.auth import get_user_model -# Create your models here. +from datetime import time + +class MedicationSettings(models.Model): + user = models.ForeignKey(get_user_model(), models.CASCADE) + + morning_from = models.TimeField(default=time(6)) + morning_till = models.TimeField(default=time(10)) + + noon_from = models.TimeField(default=time(12)) + noon_till = models.TimeField(default=time(14)) + + evening_from = models.TimeField(default=time(19)) + evening_till = models.TimeField(default=time(21)) + + night_from = models.TimeField(default=time(22)) + night_till = models.TimeField(default=time(23)) + + notifications = models.BooleanField(default=True) + refill_reminder = models.PositiveSmallIntegerField(default=7) + +class Medication(models.Model): + user = models.ForeignKey(get_user_model(), models.CASCADE) + name = models.CharField(max_length=128) + icon = models.CharField(max_length=64, default="fas fa-tablets") + + supply = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=2) + default_refill = models.PositiveSmallIntegerField(null=True, blank=True) + + morning = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=2) + noon = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=2) + evening = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=2) + night = models.DecimalField(null=True, blank=True, max_digits=5, decimal_places=2) + + remarks = models.TextField(null=True, blank=True) \ No newline at end of file