Create models for dream tracking module

Update to-do list
This commit is contained in:
Kumi 2021-01-01 14:43:47 +01:00
parent 958f6e2c75
commit 6ef8035b2f
8 changed files with 81 additions and 1 deletions

13
TODO.md
View file

@ -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
[ ] Implement Telegram webhooks
## dreams module
[ ] New dream page
[ ] Edit dream page
[ ] Delete dream page
[ ] Statistics / template tags

0
dreams/__init__.py Normal file
View file

8
dreams/admin.py Normal file
View file

@ -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)

5
dreams/apps.py Normal file
View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class DreamsConfig(AppConfig):
name = 'dreams'

49
dreams/models.py Normal file
View file

@ -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)

3
dreams/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
dreams/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -22,6 +22,7 @@ INSTALLED_APPS = [
'msgio',
'cronhandler',
'cbt',
'dreams',
]
MIDDLEWARE = [