From 6ef8035b2fcc72d5c1df1de9c63d6f6a59d5e024 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 1 Jan 2021 14:43:47 +0100 Subject: [PATCH] Create models for dream tracking module Update to-do list --- TODO.md | 13 +++++++++++- dreams/__init__.py | 0 dreams/admin.py | 8 ++++++++ dreams/apps.py | 5 +++++ dreams/models.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++ dreams/tests.py | 3 +++ dreams/views.py | 3 +++ kumify/settings.py | 1 + 8 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 dreams/__init__.py create mode 100644 dreams/admin.py create mode 100644 dreams/apps.py create mode 100644 dreams/models.py create mode 100644 dreams/tests.py create mode 100644 dreams/views.py diff --git a/TODO.md b/TODO.md index 029fd33..ed41ffb 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,9 @@ # To-Do List +## mood module + +[ ] Statistics / graphs + ## cbt module [ ] Complete thought record creation @@ -8,4 +12,11 @@ ## msgio module -[ ] Implement Telegram webhooks \ No newline at end of file +[ ] Implement Telegram webhooks + +## dreams module + +[ ] New dream page +[ ] Edit dream page +[ ] Delete dream page +[ ] Statistics / template tags \ No newline at end of file diff --git a/dreams/__init__.py b/dreams/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dreams/admin.py b/dreams/admin.py new file mode 100644 index 0000000..456c85d --- /dev/null +++ b/dreams/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +from .models import Dream, DreamMedia, DreamTheme, Theme + +admin.site.register(Dream) +admin.site.register(DreamMedia) +admin.site.register(DreamTheme) +admin.site.register(Theme) \ No newline at end of file diff --git a/dreams/apps.py b/dreams/apps.py new file mode 100644 index 0000000..1da54dc --- /dev/null +++ b/dreams/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DreamsConfig(AppConfig): + name = 'dreams' diff --git a/dreams/models.py b/dreams/models.py new file mode 100644 index 0000000..5d54a6c --- /dev/null +++ b/dreams/models.py @@ -0,0 +1,49 @@ +from django.db import models +from django.core.validators import MaxValueValidator, MinValueValidator +from django.utils import timezone +from django.contrib.auth import get_user_model + +from mood.models import Mood +from common.helpers import get_upload_path + +from colorfield.fields import ColorField + +class Theme(models.Model): + user = models.ForeignKey(get_user_model(), models.CASCADE) + name = models.CharField(max_length=64) + icon = models.CharField(default="fas fa-bed", max_length=64) + color = ColorField(default="#000000") + +class Dream(models.Model): + class DreamTypes(models.IntegerChoices): + NIGHT = 0, 'Night (main) sleep' + DAY = 1, 'Daydream' + NAP = 2, 'Napping' + + user = models.ForeignKey(get_user_model(), models.CASCADE) + title = models.CharField(max_length=64) + content = models.TextField() + type = models.IntegerField(choices=DreamTypes.choices) + mood = models.ForeignKey(Mood, models.SET_NULL, null=True) + lucid = models.BooleanField(default=False) + wet = models.BooleanField(default=False) + +class DreamTheme(models.Model): + dream = models.ForeignKey(Dream, models.CASCADE) + theme = models.ForeignKey(Theme, models.CASCADE) + +class DreamMedia(models.Model): + dream = models.ForeignKey(Dream, models.CASCADE) + media = models.FileField(get_upload_path) + +class ThemeRating(models.Model): + theme = models.ForeignKey(Theme, models.CASCADE) + name = models.CharField(max_length=64) + icon = models.CharField(default="fas fa-star", max_length=64) + color = ColorField(default="#000000") + value = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(255)]) + +class DreamThemeRating(models.Model): + dream = models.ForeignKey(Dream, models.CASCADE) + theme_rating = models.ForeignKey(ThemeRating, models.SET_NULL, null=True) + comment = models.TextField(null=True, blank=True) diff --git a/dreams/tests.py b/dreams/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/dreams/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/dreams/views.py b/dreams/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/dreams/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/kumify/settings.py b/kumify/settings.py index e0d7758..9edbd02 100644 --- a/kumify/settings.py +++ b/kumify/settings.py @@ -22,6 +22,7 @@ INSTALLED_APPS = [ 'msgio', 'cronhandler', 'cbt', + 'dreams', ] MIDDLEWARE = [